Skip to content
New issue

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

函数式组件作为Page 在支付宝小程序端使用useEffect表现错误 #4068

Closed
hisanshao opened this issue Aug 5, 2019 · 4 comments

Comments

@hisanshao
Copy link
Contributor

hisanshao commented Aug 5, 2019

问题描述
从PageA跳到PageB,再从PageB返回到PageA,此时PageB被卸载,但式PageB里面的useEffect(function () {
return function () {
// 未执行,Page引入的组件内部是可以正常执行的
}
}, [])

复现步骤
[复现问题的步骤]

  1. 从A页面跳到B页面
  2. 点击导航栏的返回按钮回到A页面
export default function PageB () {
    useEffect(() => {
        console.log(111)
        return function () {
           console.log(222)
        }
     }, [])
}

期望行为
PageB离开的时候执行console.log(222)

报错信息

return的function未被执行

系统信息

Taro v1.3.11 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。

Taro CLI 1.3.11 environment info:
System:
OS: macOS 10.14.5
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
Yarn: 1.16.0 - ~/.nvm/versions/node/v8.10.0/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
npmPackages:
@tarojs/async-await: 1.3.11 => 1.3.11
@tarojs/components: 1.3.11 => 1.3.11
@tarojs/plugin-babel: 1.3.11 => 1.3.11
@tarojs/plugin-csso: 1.3.11 => 1.3.11
@tarojs/plugin-less: 1.3.11 => 1.3.11
@tarojs/plugin-uglifyjs: 1.3.11 => 1.3.11
@tarojs/redux: 1.3.11 => 1.3.11
@tarojs/redux-h5: 1.3.11 => 1.3.11
@tarojs/router: 1.3.11 => 1.3.11
@tarojs/taro: 1.3.11 => 1.3.11
@tarojs/taro-alipay: 1.3.11 => 1.3.11
@tarojs/taro-h5: 1.3.11 => 1.3.11
@tarojs/taro-swan: 1.3.11 => 1.3.11
@tarojs/taro-tt: 1.3.11 => 1.3.11
@tarojs/taro-weapp: 1.3.11 => 1.3.11
@tarojs/webpack-runner: 1.3.11 => 1.3.11
eslint-config-taro: 1.3.11 => 1.3.11
eslint-plugin-taro: 1.3.11 => 1.3.11
nerv-devtools: ^1.4.3 => 1.4.3
nervjs: ^1.4.3 => 1.4.3
stylelint-config-taro-rn: 1.3.11 => 1.3.11
stylelint-taro-rn: 1.3.11 => 1.3.11

  • 操作系统: [e.g. macOS 10.14.5]
  • Taro 版本 [e.g. v.1.3.11]
  • Node.js 版本 [e.g. v8.10.0]
  • 报错平台 [alipay]

补充信息
错误原因:支付宝小程序taro-alipay/src/create-component.js 内的onUnload方法未添加下面这段代码,只在didUnmount内添加了,所以组件有效,Page无效。

component.hooks.forEach(function (hook) {
          if (isFunction(hook.cleanup)) {
            hook.cleanup();
          }
 });
@taro-bot
Copy link

taro-bot bot commented Aug 5, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@hisanshao hisanshao changed the title 函数式组件作为Page 使用useEffect表现错误 函数式组件作为Page 在支付宝小程序端使用useEffect表现错误 Aug 5, 2019
@hisanshao
Copy link
Contributor Author

微信和H5端是正常的

@hisanshao
Copy link
Contributor Author

这个bug还不修复吗?都一个月了 @luckyadam

@AEPKILL
Copy link

AEPKILL commented Oct 23, 2019

同样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants