From f88a81615b78f1f74cd6a8a1e1615c5b0b93e94f Mon Sep 17 00:00:00 2001 From: Jefferson Aux Date: Mon, 23 Sep 2019 14:51:29 +0800 Subject: [PATCH 1/2] update componentWillMount to componentDidMount --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index ad60eccd..14592ad0 100644 --- a/index.js +++ b/index.js @@ -117,7 +117,7 @@ export default class Drawer extends Component { this._childDrawer = drawer } - componentWillMount() { + componentDidMount() { if (this.context.drawer) this.context.drawer._registerChildDrawer(this) if (this.props.openDrawerThreshold && process.env.NODE_ENV !== 'production') console.error('react-native-drawer: openDrawerThreshold is obsolete. Use panThreshold instead.') if (this.props.panStartCompensation && process.env.NODE_ENV !== 'production') console.error('react-native-drawer: panStartCompensation is deprecated.') From 1446b0060d71a85e9d518cd17582c766e8fa9910 Mon Sep 17 00:00:00 2001 From: Jefferson Aux Date: Mon, 23 Sep 2019 18:07:30 +0800 Subject: [PATCH 2/2] moved codes from componentWillReceiveProps to componentDidUpdate --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 14592ad0..86bf87de 100644 --- a/index.js +++ b/index.js @@ -125,16 +125,14 @@ export default class Drawer extends Component { this.initialize(this.props) } - componentWillReceiveProps(nextProps) { - if (this.requiresResync(nextProps)) this.resync(null, nextProps) + componentDidUpdate() { + if (this.requiresResync(this.props)) this.resync(null, this.props) - if (nextProps.open !== null && this._open !== nextProps.open) { + if (this.props.open !== null && this._open !== this.props.open) { this._syncAfterUpdate = true - this._open = nextProps.open + this._open = this.props.open } - } - componentDidUpdate() { if (this._syncAfterUpdate) { this._syncAfterUpdate = false this._open ? this.open('force') : this.close('force')