From 3450d4b17e7b618f0b5a8d9d0116b03e8d116e04 Mon Sep 17 00:00:00 2001 From: Matt Rabe Date: Tue, 7 Jan 2020 11:45:32 -1000 Subject: [PATCH] fix(src/index.js): Re #186: onAfter called after preload in 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 #186 --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 9f2c0ba..87d7bc1 100644 --- a/src/index.js +++ b/src/index.js @@ -240,9 +240,8 @@ export default function universal( 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) { @@ -261,6 +260,7 @@ export default function universal( componentDidMount() { this._initialized = true + this.state = this.init(this.props, this.context) } componentDidUpdate(prevProps: Props) {