Skip to content

Instantly share code, notes, and snippets.

@thelicato
Last active July 31, 2020 17:36
Show Gist options
  • Save thelicato/72653e9746ec0a589907c704c858204f to your computer and use it in GitHub Desktop.
Save thelicato/72653e9746ec0a589907c704c858204f to your computer and use it in GitHub Desktop.
const MyDiagram = () => {
// create diagrams schema
const [schema, setSchema] = useState(initialSchema);
const addNode = () => {
var new_node = {
//new node data
}
var new_schema = Object.assign({},schema)
new_schema.nodes.push(new_node)
setSchema(new_schema)
}
return (
<div style={{ height: '22.5rem' }}>
<button onClick={addNode}>addNode</button>
<Diagram schema={schema} onChange={setSchema}/>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment