diff --git a/client/index.js b/client/index.js index 148556fc..9259b446 100644 --- a/client/index.js +++ b/client/index.js @@ -2,7 +2,7 @@ import React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' import configureStore from '../shared/redux/store/configureStore' -import App from '../shared/components/App/App' +import App from '../shared/containers/App/App' const initialState = window.__INITIAL_STATE__ const store = configureStore(initialState) diff --git a/shared/components/App/App.jsx b/shared/components/App/App.jsx deleted file mode 100644 index 9aaf3f41..00000000 --- a/shared/components/App/App.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import Editor from '../Editor/Editor' -import { bindActionCreators } from 'redux' -import { connect } from 'react-redux' -import * as FileActions from '../../redux/actions' - -function mapStateToProps(state) { - return { - file: state.file - } -} - -function mapDispatchToProps(dispatch) { - return bindActionCreators(FileActions, dispatch); -} - -export default connect(mapStateToProps, mapDispatchToProps)(Editor); \ No newline at end of file diff --git a/shared/components/Editor/Editor.jsx b/shared/components/Editor/Editor.jsx index 3fc34a06..d25f159a 100644 --- a/shared/components/Editor/Editor.jsx +++ b/shared/components/Editor/Editor.jsx @@ -12,7 +12,7 @@ class Editor extends React.Component { componentDidMount() { this._cm = CodeMirror(this.refs.container, { theme: 'p5-widget', - value: this.props.file.content, + value: this.props.content, // value: "var a = 'Hello World!';", lineNumbers: true, mode: 'javascript' @@ -23,9 +23,9 @@ class Editor extends React.Component { } componentDidUpdate(prevProps) { - if (this.props.file.content !== prevProps.file.content && - this.props.file.content !== this._cm.getValue()) { - this._cm.setValue(this.props.file.content); + if (this.props.content !== prevProps.content && + this.props.content !== this._cm.getValue()) { + this._cm.setValue(this.props.content); } } diff --git a/shared/containers/App/App.jsx b/shared/containers/App/App.jsx new file mode 100644 index 00000000..6acecd14 --- /dev/null +++ b/shared/containers/App/App.jsx @@ -0,0 +1,27 @@ +import React from 'react'; +import Editor from '../../components/Editor/Editor' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import * as FileActions from '../../redux/actions' + +class App extends React.Component { + render() { + return ( + + ); + } +} + +function mapStateToProps(state) { + return { + file: state.file + } +} + +function mapDispatchToProps(dispatch) { + return bindActionCreators(FileActions, dispatch); +} + +export default connect(mapStateToProps, mapDispatchToProps)(App); \ No newline at end of file