Skip to content

Commit

Permalink
fix(src/index.js): Re faceyspacey#186: onAfter called after preload i…
Browse files Browse the repository at this point in the history
…n V3 but not V4

Move init() call from constructor to componentDidMount, after _initialize is set to true, so that
__update() fires __handleAfter on first run

fix faceyspacey#186
  • Loading branch information
mattrabe committed Jan 7, 2020
1 parent 8133dae commit 3450d4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ export default function universal<Props: Props>(

constructor(props: Props, context: {}) {
super(props, context)
this.state = this.init(this.props, this.context)
// $FlowFixMe
this.state.error = null
this.state = { error: null }
}

static getDerivedStateFromProps(nextProps, currentState) {
Expand All @@ -261,6 +260,7 @@ export default function universal<Props: Props>(

componentDidMount() {
this._initialized = true
this.state = this.init(this.props, this.context)
}

componentDidUpdate(prevProps: Props) {
Expand Down

0 comments on commit 3450d4b

Please sign in to comment.