React Tips
Append the new data to the existing state
Use function in set
state
useEffect(() => { if (graphData) { setNodes(prevNodes => [...prevNodes, ...graphData.nodes]); setLinks(graphData.links); }}, [graphData]);
Conditionally join class names
Use classnames
: https://github.com/JedWatson/classnames
classNames('foo', 'bar'); // => 'foo bar'classNames('foo', { bar: true }); // => 'foo bar'classNames({ 'foo-bar': true }); // => 'foo-bar'classNames({ 'foo-bar': false }); // => ''classNames({ foo: true }, { bar: true }); // => 'foo bar'classNames({ foo: true, bar: true }); // => 'foo bar'