Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

[BUG] 页面生命周期会重复触发 #1288

Closed
noyobo opened this issue Sep 16, 2020 · 1 comment · Fixed by #1289
Closed

[BUG] 页面生命周期会重复触发 #1288

noyobo opened this issue Sep 16, 2020 · 1 comment · Fixed by #1289
Labels
bug Something isn't working

Comments

@noyobo
Copy link
Contributor

noyobo commented Sep 16, 2020

bug 描述

在 onPageCompnent 中的组件生命触发有误,Modal 组件内的 onShow onHide 切换页面重复触发。

const React = require('react');
const Modal = require('../src/components/Modal').default;

module.exports = {
    onPageComponent({ component, page }) {
        // 注意这里一定要用 React.forwardRef 把 ref 传下去
        return React.forwardRef((props, ref) => {
            return React.createElement(
                React.Fragment,
                null,
                React.createElement(
                    Modal,
                    { page },
                    React.createElement(component, { ...props, ref })
                )
            );
        });
    },
};

复现步骤

  1. clone https://github.com/remaxjs/examples/tree/bug/plugin-lifecycle
    cd wechat
    yarn install
  2. yarn run dev
  3. 打开微信开发者工具
  4. 切换页面
  5. 观察 log 切换页面后 log 会递增如附件
    https://github.com/remaxjs/examples/blob/172ee02f4cab27c5d2ec05e5772bc6b0849d0222/wechat/src/components/Modal.js#L6

期望结果
[描述你原本期望看到的结果]

复现代码
https://github.com/remaxjs/examples/tree/bug/plugin-lifecycle

版本信息:

  • remax 版本: 2.8.0

其他信息

image

@noyobo noyobo added the bug Something isn't working label Sep 16, 2020
@noyobo
Copy link
Contributor Author

noyobo commented Sep 16, 2020

补充移除 plugin 后,页面中 onShow, onHide 事件也会如此

@Darmody Darmody changed the title [BUG] 在 onPageCompnent 中的组件生命触发错误 [BUG] 页面生命周期会重复触发 Sep 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant