Skip to content

Commit

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

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

fix #186
  • Loading branch information
mattrabe authored and ScriptedAlchemy committed Jan 18, 2020
1 parent 8133dae commit 3a5d88b
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 3a5d88b

Please sign in to comment.