Custom Node Development
In Data-River, nodes (blocks) are customizable React components. Each node can have its own visual representation, input/output handles, and configurable settings.
This guide will walk you through how to create a custom node for the Data-River editor.
Node Structure
A node consists of the following elements:
NodeProps: Props passed from React Flow containing node-specific data.
Input and Output Handles: Used for connecting the node to other nodes in the workflow.
Node UI: Visual representation, including controls, icons, and labels.
Example Custom Node
Here’s a basic example of a custom node:
How to Use Custom Nodes
Define the Node Create your node by defining a React component that extends
NodeProps
from React Flow. Add any custom UI elements and define how the node will appear and behave.Handle Inputs and Outputs Use
SourceHandle
andTargetHandle
components to define where connections can be made to and from this node.Register the Node Once the node is created, register it in
Flow.tsx
by adding it to thenodeTypes
object or just use the default type custom:Test Your Node Run the editor locally and test your custom node by adding it to a workflow. Ensure that the input/output handles work as expected.
Best Practices
Keep It Simple: Nodes should be simple and intuitive to use.
UI Consistency: Ensure that your node matches the styling of other nodes in the platform.
Handle Errors Gracefully: Use error handling to ensure that the node behaves correctly even if invalid inputs are provided.
What's Next?
Last updated