Skip to content
This repository was archived by the owner on Apr 18, 2022. It is now read-only.

Commit c9655da

Browse files
committed
Fix issue with re-render occuring on initial mount.
1 parent cf03554 commit c9655da

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/redux.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,24 @@ class Redux extends React.Component {
1717
})
1818

1919
// Get initial state
20-
this.selectorToState()
20+
const { selector } = this.props
21+
const state = selector(store.getState())
22+
this.selectedState = state
2123
}
2224

2325
selectorToState() {
2426
const { selector } = this.props
2527
const store = this.context.reduxRenderStore
2628
const state = selector(store.getState())
27-
if (state !== this.state) {
28-
this.setState(state)
29+
if (state !== this.selectedState) {
30+
this.selectedState = state
31+
this.forceUpdate()
2932
}
3033
}
3134

3235
render() {
3336
return this.props.children(
34-
this.state,
37+
this.selectedState,
3538
this.context.reduxRenderStore.dispatch
3639
)
3740
}

0 commit comments

Comments
 (0)