diff --git a/src/components/blocks.js b/src/components/blocks.js index 73c173a96..0d05a95f0 100644 --- a/src/components/blocks.js +++ b/src/components/blocks.js @@ -3,12 +3,13 @@ const React = require('react'); const ScratchBlocks = require('scratch-blocks'); class Blocks extends React.Component { - componentDidUpdate (prevProps) { - if (!prevProps.options.toolbox && this.props.options.toolbox) { - let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options); - this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig); - this.props.onReceiveWorkspace(this.workspace); - } + componentDidMount () { + let workspaceConfig = defaultsDeep({}, Blocks.defaultOptions, this.props.options); + this.workspace = ScratchBlocks.inject(this.refs.scratchBlocks, workspaceConfig); + this.props.onReceiveWorkspace(this.workspace); + } + componentWillUnmount () { + this.workspace.dispose(); } render () { return ( diff --git a/src/components/gui.js b/src/components/gui.js index 59d306042..38488311e 100644 --- a/src/components/gui.js +++ b/src/components/gui.js @@ -6,7 +6,6 @@ const Renderer = require('scratch-render'); const SpriteSelector = require('./sprite-selector'); const Stage = require('./stage'); const StopAll = require('./stop-all'); -const Toolbox = require('./toolbox'); const VM = require('scratch-vm'); const VMManager = require('../lib/vm-manager'); @@ -17,11 +16,6 @@ class GUI extends React.Component { this.onReceiveWorkspace = this.onReceiveWorkspace.bind(this); this.state = {}; } - componentDidMount () { - this.setState({ - toolbox: this.toolbox - }); - } componentWillReceiveProps (nextProps) { if (this.props.projectData !== nextProps.projectData) { this.props.vm.loadProject(nextProps.projectData); @@ -58,11 +52,9 @@ class GUI extends React.Component { this.stage = stage} /> - this.toolbox = toolbox} /> - {this.props.children} - - ); - } -} - -Toolbox.propTypes = { - children: React.PropTypes.node, - toolboxRef: React.PropTypes.func -}; - -Toolbox.defaultProps = { - toolboxRef: function () {}, - children: [ - - - - - 10 - - - - - - - 15 - - - - - - - 15 - - - - - - - 90 - - - - - - - - - - - - - 0 - - - - - 0 - - - - - - - - - - - - - 1 - - - - - 0 - - - - - 0 - - - - - - - 10 - - - - - - - 0 - - - - - - - 10 - - - - - - - 0 - - - - - - - - - - - - - , - - - - - Hello! - - - - - 2 - - - - - - - Hello! - - - - - - - Hmm... - - - - - 2 - - - - - - - Hmm... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - - - - - - - - - - 10 - - - - - - - - 10 - - - - - - - 100 - - - - - - - - 1 - - - - - - - - , - - - - - - - - - - - - - - - - 1 - - - - - 0.25 - - - - - - - 0.25 - - - - - - - 1 - - - - - 0.5 - - - - - - - 1 - - - - - - - - - 10 - - - - - - - - 100 - - - - - - - -10 - - - - - - - 100 - - - - - - - - 20 - - - - - - - 60 - - - - - , - - - - - - - - - - - - - - - 10 - - - - - - - 0 - - - - - - - 10 - - - - - - - 50 - - - - - - - 1 - - - - - - - 1 - - - - , - , - - - - - - - - - - - - - - - - - - - - 10 - - - - - - - - - - - - - - - - - - - , - - - - - 1 - - - - - - - 10 - - - - - - - - - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - - - - - What's your name? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - hello - - - - - world - - - - - - - 1 - - - - - world - - - - - - - world - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - ] -}; - -module.exports = Toolbox;