diff --git a/src/components/Blockly/BlocklyComponent.jsx b/src/components/Blockly/BlocklyComponent.jsx index 9d5696e..627df9a 100644 --- a/src/components/Blockly/BlocklyComponent.jsx +++ b/src/components/Blockly/BlocklyComponent.jsx @@ -68,7 +68,7 @@ class BlocklyComponent extends React.Component { return - + ; } diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index f07d8f0..ca70826 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -28,31 +28,44 @@ class BlocklyWindow extends Component { }); } + componentDidUpdate(props) { + if(props.initialXml !== this.props.initialXml){ + // guarantees that the current xml-code (this.props.initialXml) is rendered + const workspace = Blockly.getMainWorkspace(); + workspace.clear(); + Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(this.props.initialXml), workspace); + } + } + render() { + console.log(this.props.initialXml); return (