Skip to content

Commit

Permalink
fix(taro-weapp): 修复父组件 setState null 时,传到子组件时被过滤掉的问题 fix #1151
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-jj committed Nov 21, 2018
1 parent 84315ea commit 0ec931d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/taro-weapp/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ function filterProps (properties, defaultProps = {}, componentProps = {}, weappC
}
if (typeof componentProps[propName] === 'function') {
newProps[propName] = componentProps[propName]
} else if (propName in weappComponentData &&
(properties[propName].value !== null || weappComponentData[propName] !== null)) {
} else if (propName in weappComponentData) {
newProps[propName] = weappComponentData[propName]
}
if (componentFnReg.test(propName)) {
Expand All @@ -205,7 +204,7 @@ function filterProps (properties, defaultProps = {}, componentProps = {}, weappC
}
if (!isEmptyObject(defaultProps)) {
for (const propName in defaultProps) {
if (newProps[propName] === undefined) {
if (newProps[propName] === undefined || newProps[propName] === null) {
newProps[propName] = defaultProps[propName]
}
}
Expand Down

2 comments on commit 0ec931d

@flappyjet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果defaultProps[propName]有非null值,同时weappComponentData[propName] === null,不就不生效了吗

@Chen-jj
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种情况使用 defaultProps 的值,是正确的

Please sign in to comment.