import React, { useEffect } from 'react';

export const DecisionNode = (props) => {
  const {activeNode} = props;
    useEffect(() => {
      let sub;
      if (activeNode && activeNode.decision) {
       sub = activeNode.decision(props).subscribe();
      } else {
        throw new Error('One of the decision nodes exists without any decision. Add at least one decision to the node in the manifest.');
      }
      return () => {
        if (sub) sub.unsubscribe();
      };
    },[activeNode, props]);
  return (
    <>
      Loading...
    </>
  );
};

