We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
微信小程序
https://github.com/myl0204/taro2-bug-report 小程序基础库: 2.14.1 使用框架: React
PureComponent
setState
dispatch
this.setState({})
触发事件回调后,redux传递给组件的props的值发生了改变,而视图未更新.
debug后发现,dispatch更改props的值时候,同时更改了prevProps对应的值,造成了在SCU阶段认为组件的state、props未发生更新,故视图未更新。
SCU
state
props
// 更改props的代码 https://github.com/NervJS/taro/blob/2.x/packages/taro-redux/src/connect/connect.js#L39 if (this.props[key] !== val) { this.props[key] = val isChanged = true } // props和prevProps指向同一变量 // https://github.com/NervJS/taro/blob/2.x/packages/taro-weapp/src/lifecycle.js#L91 // https://github.com/NervJS/taro/blob/2.x/packages/taro-weapp/src/lifecycle.js#L118 // 在上面更改props时,同时更改了prevProps component.prevProps = component.props // 由于之前触发过一次enqueueRender,以下逻辑不会执行 // https://github.com/NervJS/taro/blob/2.x/packages/taro-redux/src/connect/connect.js#L44 if (!this._dirty) { this.prevProps = prevProps; }
在赋值的时候是否可以做一层浅复制?
视图更新
视图不更新
Taro CLI 2.2.16 environment info: System: OS: macOS 11.2.1 Shell: 5.8 - /bin/zsh Binaries: Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node Yarn: 1.19.1 - ~/.nvm/versions/node/v10.16.3/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm npmPackages: @tarojs/components: 2.2.16 => 2.2.16 @tarojs/components-qa: 2.2.16 => 2.2.16 @tarojs/mini-runner: 2.2.16 => 2.2.16 @tarojs/plugin-terser: 2.2.16 => 2.2.16 @tarojs/redux: 2.2.16 => 2.2.16 @tarojs/redux-h5: 2.2.16 => 2.2.16 @tarojs/router: 2.2.16 => 2.2.16 @tarojs/taro: 2.2.16 => 2.2.16 @tarojs/taro-alipay: 2.2.16 => 2.2.16 @tarojs/taro-h5: 2.2.16 => 2.2.16 @tarojs/taro-qq: 2.2.16 => 2.2.16 @tarojs/taro-quickapp: 2.2.16 => 2.2.16 @tarojs/taro-rn: 2.2.16 => 2.2.16 @tarojs/taro-swan: 2.2.16 => 2.2.16 @tarojs/taro-tt: 2.2.16 => 2.2.16 @tarojs/taro-weapp: 2.2.16 => 2.2.16 @tarojs/webpack-runner: 2.2.16 => 2.2.16 eslint-config-taro: 2.2.16 => 2.2.16 eslint-plugin-taro: 2.2.16 => 2.2.16 nerv-devtools: ^1.5.5 => 1.5.7 nervjs: ^1.5.5 => 1.5.7 stylelint-config-taro-rn: 2.2.16 => 2.2.16 stylelint-taro-rn: 2.2.16 => 2.2.16
The text was updated successfully, but these errors were encountered:
fix(redux): 特殊情况下redux更新无法触发视图更新, fix NervJS#8705
2462436
fix(redux): 特殊情况下redux更新无法触发视图更新, fix #8705 (#8709)
4e89ff2
* fix(redux): 特殊情况下redux更新无法触发视图更新, fix #8705 * fix: 语法错误
您好,3.x也同时存在这个问题,麻烦修复一下哦~
Sorry, something went wrong.
No branches or pull requests
相关平台
微信小程序
复现仓库
https://github.com/myl0204/taro2-bug-report
小程序基础库: 2.14.1
使用框架: React
复现步骤
PureComponent
setState
以及dispatch
一个actionsetState
*指的是类似this.setState({})
或者setState的值与当前值一致触发事件回调后,redux传递给组件的props的值发生了改变,而视图未更新.
问题分析
debug后发现,dispatch更改props的值时候,同时更改了prevProps对应的值,造成了在
SCU
阶段认为组件的state
、props
未发生更新,故视图未更新。导致了最后
SCU
返回false讨论
在赋值的时候是否可以做一层浅复制?
期望结果
视图更新
实际结果
视图不更新
环境信息
The text was updated successfully, but these errors were encountered: