diff --git a/.gitignore b/.gitignore index d01b47a..bf21202 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules .next cypress/videos cypress/screenshots +.idea diff --git a/components/Editor.js b/components/Editor.js index 1252911..c6395a8 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -41,14 +41,11 @@ const saveButtonOptions = { class Editor extends React.Component { constructor(props) { super(props) - this.state = Object.assign( - { - ...DEFAULT_SETTINGS, - uploading: false, - code: props.content - }, - this.props.initialState - ) + this.state = { + ...DEFAULT_SETTINGS, + uploading: false, + code: props.content + } this.save = this.save.bind(this) this.upload = this.upload.bind(this) @@ -65,13 +62,11 @@ class Editor extends React.Component { } componentDidMount() { - // Load from localStorage instead of query params - if (!this.props.initialState) { - const state = getState(localStorage) - if (state) { - this.setState(state) - } - } + // Load from localStorage and then URL params + this.setState({ + ...getState(localStorage), + ...this.props.initialState + }) } componentDidUpdate() {