Skip to content

Commit

Permalink
Fix MiddlewareApp never properly applying settings passed as props. (…
Browse files Browse the repository at this point in the history
…#836)
  • Loading branch information
leonaves authored and huv1k committed Oct 15, 2018
1 parent 79aaa2a commit f57bb5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import * as React from 'react'
import { Provider } from 'react-redux'
import createStore from '../state/createStore'
import { getSettings } from '../state/workspace/reducers'
import { setSettingsString } from '../state/general/actions'
import PlaygroundWrapper, { PlaygroundWrapperProps } from './PlaygroundWrapper'

const store = createStore()

export default class MiddlewareApp extends React.Component<
PlaygroundWrapperProps
> {
componentDidMount() {
const initialSettings = getSettings(store.getState())
const mergedSettings = { ...initialSettings, ...this.props.settings }
const settingsString = JSON.stringify(mergedSettings, null, 2)
store.dispatch(setSettingsString(settingsString))
}
render() {
return (
<Provider store={store}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class PlaygroundWrapper extends React.Component<

const mapStateToProps = (state, ownProps) => {
const theme = ownProps.theme || getTheme(state, ownProps.settings)
const settings = ownProps.settings || getSettings(state)
const settings = getSettings(state)
return { theme, settings }
}

Expand Down

0 comments on commit f57bb5c

Please sign in to comment.