Guides -> Custom Nodes -> Implementing the Custom Node

master
Jason Zhu 2023-05-29 21:30:52 +10:00
parent 8d70c86460
commit b45ee8f5cc
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
import { useCallback } from 'react';
import { Handle, Position } from 'reactflow';
const handleStyle = { left: 10 };
const TextUpdaterNode = ({ data }) => {
const onChange = useCallback(evt => {
console.log(evt.target.value);
}, []);
return (
<>
<Handle type={'target'} position={Position.Top} />
<div>
<label htmlFor={'text'}>Text:</label>
<input
id={'text'}
name={'text'}
onChange={onChange}
className={'nodrag'}
/>
</div>
<Handle type={'source'} position={Position.Bottom} id={'a'} />
<Handle
type={'source'}
position={Position.Bottom}
id={'b'}
style={handleStyle}
/>
</>
);
};