You’re missing the React option. You do not manually modify the item tree. You declaratively map properties / state to elements and let React make all changes.
var App = React.createClass({
render: function() {
var node = this.props.node;
var components = node.map(function(props) {
return React.createElement('g', {
id: props.id,
key: props.id
},
React.createElement('path', props));
});
return React.createElement('div', null, components);
}
});
function renderApp(node, element) {
ReactDOM.render(React.createElement(App, { node: node }), element);
}
function destroyApp(element) {
ReactDOM.unmountComponentAtNode(element);
}
var node = Interfaces.Embroidery.node;
renderApp(node, document.getElementById('parentDrawingNode'));
function updateNodeOnSomeUserActionThatHappensOutsideOfReact(...) {
node.push(...);
renderApp(node, document.getElementById('parentDrawingNode'));
}
: https://facebook.imtqy.com/react/blog/2015/10/01/react-render-and-top-level-api.html
: , , " " React (.. ). " " React, render , state this.setState({ node: modifiedNodes });, , React DOM.