From 85141db72444dc201c3b655ce90ea801c0563307 Mon Sep 17 00:00:00 2001 From: "Mr.Tone" Date: Tue, 28 Jun 2016 20:01:02 +0800 Subject: [PATCH] =?UTF-8?q?Transfer=20=E7=BB=84=E4=BB=B6=E5=9C=A8render?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=A9=AC=E4=B8=8Aunmount=E4=BC=9A=E6=8A=A5se?= =?UTF-8?q?tState=E9=94=99=E8=AF=AF=20(#2206)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Transfer 组件在render后,马上unmount会报setState错误 如题 * _t => timer --- components/transfer/list.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index b665cd1ade..f4d9eeb7e8 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -54,13 +54,17 @@ export default class TransferList extends React.Component { } componentDidMount() { - setTimeout(() => { + this.timer = setTimeout(() => { this.setState({ mounted: true, }); }, 0); } + componentWillUnmount() { + clearTimeout(this.timer); + } + shouldComponentUpdate(...args) { return PureRenderMixin.shouldComponentUpdate.apply(this, args); }