Skip to content

Commit

Permalink
fix(wx-react): 修复FlatList,SectionList组件销毁时报错
Browse files Browse the repository at this point in the history
fix #47
  • Loading branch information
ykforerlang committed Jan 8, 2020
1 parent 791046c commit 3b1d381
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/wx-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@areslabs/wx-react",
"version": "2.2.1",
"version": "2.2.2",
"description": "微信版本的React",
"files": [
"package.json",
Expand Down
15 changes: 11 additions & 4 deletions packages/wx-react/src/reactCompHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
},
})
Expand Down

0 comments on commit 3b1d381

Please sign in to comment.