From 3b1d38106a4747f79a6e3289ed59aebaf4ff8f89 Mon Sep 17 00:00:00 2001 From: ykforerlang <1527997464@qq.com> Date: Wed, 8 Jan 2020 10:44:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(wx-react):=20=E4=BF=AE=E5=A4=8DFlatList?= =?UTF-8?q?=EF=BC=8CSectionList=E7=BB=84=E4=BB=B6=E9=94=80=E6=AF=81?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #47 --- packages/wx-react/package.json | 2 +- packages/wx-react/src/reactCompHelper.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/wx-react/package.json b/packages/wx-react/package.json index 0224dbb..80bafa8 100644 --- a/packages/wx-react/package.json +++ b/packages/wx-react/package.json @@ -1,6 +1,6 @@ { "name": "@areslabs/wx-react", - "version": "2.2.1", + "version": "2.2.2", "description": "微信版本的React", "files": [ "package.json", diff --git a/packages/wx-react/src/reactCompHelper.js b/packages/wx-react/src/reactCompHelper.js index d6872eb..8b151cb 100644 --- a/packages/wx-react/src/reactCompHelper.js +++ b/packages/wx-react/src/reactCompHelper.js @@ -19,10 +19,17 @@ export default function reactCompHelper(obj) { const rawData = this.data Object.defineProperty(this, 'data', { get: function () { - const compInst = instanceManager.getCompInstByUUID(rawData.diuu); - return { - ...rawData, - ...compInst.props + + // 当FlatList SectionList等继承PureComponent/Component组件存在的时候,其销毁是在react过程就完成的 + // 这里detached调用this.data.diuu 会导致这里的compInst为null + const compInst = instanceManager.getCompInstByUUID(rawData.diuu); + if (!compInst) { + return rawData + } else { + return { + ...rawData, + ...compInst.props + } } }, })