Flow Chart Structure
Overview
Key Components of the Flow Chart
<ReactFlow nodes={nodes} edges={edges} onNodesChange={eventHandlers.onNodesChangeHandler} onEdgesChange={eventHandlers.onEdgesChangeHandler} onConnect={eventHandlers.onConnect} nodeTypes={nodeTypes} // Always uses the generic 'custom' node type edgeTypes={edgeTypes} connectionMode={ConnectionMode.Loose} minZoom={0.5} maxZoom={3} > <Background /> <Controls /> </ReactFlow>const initialNodes: CustomNode[] = [ { id: "2", type: "custom", position: { x: 400, y: 100 }, data: { block: "[email protected]", label: "Input node", color: "rgb(234 179 8)", sourceHandle: true, targetHandle: true, icon: "TextCursorInput", inputs: { input: "" }, outputs: { output: "" }, controls: [ { type: "text", label: "Value", name: "input", placeholder: "Pass to output", }, ], }, }, ];const NodeControls: React.FC<NodeControlsProps> = ({ nodeId, controls }) => { return controls.map((control, index) => { if (control.type === "text") { return ( <InputWithLabel key={index} label={control.label} placeholder={control.placeholder} value={control.value} onChange={(newValue) => handleInputChange(nodeId, control.name, newValue)} /> ); } // Handle other control types... }); };const initialEdges: Edge[] = [ { id: "e1-2", source: "1", target: "2", type: "custom" }, ];const eventHandlers = useReactFlowEventHandlers(); <ReactFlow onNodesChange={eventHandlers.onNodesChangeHandler} onEdgesChange={eventHandlers.onEdgesChangeHandler} onConnect={eventHandlers.onConnect} />
Working with Nodes and Data
Node Data Structure
Dynamic Node Rendering
Node Controls and Interaction
Best Practices
What's Next?
Last updated
Was this helpful?