refactor(examples): cleanup

This commit is contained in:
moklick
2020-07-27 12:36:47 +02:00
parent a436260a1c
commit cbc41f244e
4 changed files with 30 additions and 19 deletions

View File

@@ -13,6 +13,8 @@ const initialElements = [
const isValidConnection = (connection) => connection.target === 'B';
const onLoad = (reactFlowInstance) => reactFlowInstance.fitView();
const CustomInput = () => (
<>
<div>Only connectable with B</div>
@@ -28,6 +30,11 @@ const CustomNode = ({ id }) => (
</>
);
const nodeTypes = {
custominput: CustomInput,
customnode: CustomNode,
};
const HorizontalFlow = () => {
const [elements, setElements] = useState(initialElements);
const onConnect = (params) => setElements((els) => addEdge(params, els));
@@ -37,12 +44,9 @@ const HorizontalFlow = () => {
elements={elements}
onConnect={onConnect}
selectNodesOnDrag={false}
onLoad={(reactFlowInstance) => reactFlowInstance.fitView()}
onLoad={onLoad}
className="validationflow"
nodeTypes={{
custominput: CustomInput,
customnode: CustomNode,
}}
nodeTypes={nodeTypes}
/>
);
};