fix issue #321 - load defaults, then localStorage, then url config (#322)

* fix issue #321 - load defaults, then localStorage, then url config

* update comment and also do not need current state
main
Steven Sacks 7 years ago committed by Michael Fix
parent f49b7649fb
commit 9e519e2b5f

1
.gitignore vendored

@ -3,3 +3,4 @@ node_modules
.next
cypress/videos
cypress/screenshots
.idea

@ -41,14 +41,11 @@ const saveButtonOptions = {
class Editor extends React.Component {
constructor(props) {
super(props)
this.state = Object.assign(
{
this.state = {
...DEFAULT_SETTINGS,
uploading: false,
code: props.content
},
this.props.initialState
)
}
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() {

Loading…
Cancel
Save