#1289 fix: 修复同一页面的生命周期会重复触发的问题

Merged Cai Huanyu Darmody
Coverage Reach
remax-cli/src/build/webpack/plugins/NativeFiles/createPageTemplate.ts remax-cli/src/build/webpack/plugins/NativeFiles/index.ts remax-cli/src/build/webpack/plugins/NativeFiles/createTurboPageTemplate.ts remax-cli/src/build/webpack/plugins/NativeFiles/getUsingComponents.ts remax-cli/src/build/webpack/plugins/NativeFiles/createPageManifest.ts remax-cli/src/build/webpack/plugins/NativeFiles/createAppManifest.ts remax-cli/src/build/webpack/plugins/NativeFiles/cacheable.ts remax-cli/src/build/webpack/plugins/RuntimeOptions.ts remax-cli/src/build/webpack/plugins/OptimizeEntries.ts remax-cli/src/build/webpack/plugins/WebEntryWatcher.ts remax-cli/src/build/webpack/plugins/CoverageIgnore.ts remax-cli/src/build/webpack/plugins/index.ts remax-cli/src/build/webpack/loaders/nativeComponent/jsHelper.ts remax-cli/src/build/webpack/loaders/nativeComponent/modules.ts remax-cli/src/build/webpack/loaders/nativeComponent/usingComponents.ts remax-cli/src/build/webpack/loaders/nativeComponent/template.ts remax-cli/src/build/webpack/loaders/nativeComponent/style.ts remax-cli/src/build/webpack/loaders/nativeComponent/index.ts remax-cli/src/build/webpack/loaders/nativeComponent/getAssets.ts remax-cli/src/build/webpack/loaders/nativeComponent/json.ts remax-cli/src/build/webpack/loaders/babel.ts remax-cli/src/build/webpack/loaders/stub.ts remax-cli/src/build/webpack/config.mini.ts remax-cli/src/build/webpack/config.web.ts remax-cli/src/build/webpack/config/css.ts remax-cli/src/build/webpack/baseConfig.ts remax-cli/src/build/babel/compiler/static/render/templates/attributes.ts remax-cli/src/build/babel/compiler/static/render/templates/JSXElement.ts remax-cli/src/build/babel/compiler/static/render/templates/index.ts remax-cli/src/build/babel/compiler/static/render/templates/TemplateInfoMap.ts remax-cli/src/build/babel/compiler/static/render/templates/JSXExpressionContainer.ts remax-cli/src/build/babel/compiler/static/render/templates/stringPath.ts remax-cli/src/build/babel/compiler/static/render/index.ts remax-cli/src/build/babel/compiler/static/helpers.ts remax-cli/src/build/babel/compiler/static/postProcess.ts remax-cli/src/build/babel/compiler/static/preprocess/JSXExpressionContainer.ts remax-cli/src/build/babel/compiler/static/preprocess/JSXElement.ts remax-cli/src/build/babel/compiler/static/preprocess/index.ts remax-cli/src/build/babel/compiler/static/constants.ts remax-cli/src/build/babel/compiler/static/index.ts remax-cli/src/build/babel/componentManifest.ts remax-cli/src/build/babel/page.ts remax-cli/src/build/babel/app.ts remax-cli/src/build/babel/pageEvent.ts remax-cli/src/build/babel/appEvent.ts remax-cli/src/build/babel/fixRegeneratorRuntime.ts remax-cli/src/build/utils/modules.ts remax-cli/src/build/utils/env.ts remax-cli/src/build/utils/nativeComponent.ts remax-cli/src/build/utils/paths.ts remax-cli/src/build/utils/web.ts remax-cli/src/build/utils/output.ts remax-cli/src/build/utils/turboPages.ts remax-cli/src/build/utils/alias.ts remax-cli/src/build/utils/getAppConfig.ts remax-cli/src/build/web.ts remax-cli/src/build/mini.ts remax-cli/src/build/index.ts remax-cli/src/build/watch.ts remax-cli/src/API.ts remax-cli/src/getEntries.ts remax-cli/src/readManifest.ts remax-cli/src/getConfig.ts remax-cli/src/index.ts remax-cli/src/defaultOptions/UNSAFE_wechatTemplateDepth.ts remax-cli/src/defaultOptions/index.ts remax-cli/src/extensions.ts remax-cli/src/remaxVersion.ts remax-cli/postcss.config.js remax-runtime/src/hostConfig/index.ts remax-runtime/src/hostConfig/diffProperties.ts remax-runtime/src/VNode.ts remax-runtime/src/createPageConfig.ts remax-runtime/src/createAppConfig.ts remax-runtime/src/Container.ts remax-runtime/src/lifecycle/index.ts remax-runtime/src/lifecycle/events.ts remax-runtime/src/utils/plainStyle/index.ts remax-runtime/src/utils/plainStyle/CSSProperty.ts remax-runtime/src/utils/isClassComponent.ts remax-runtime/src/utils/capitalize.ts remax-runtime/src/utils/lowercase.ts remax-runtime/src/SyntheticEvent/createCallbackProxy.ts remax-runtime/src/SyntheticEvent/stopPropagation.ts remax-runtime/src/SyntheticEvent/constants.ts remax-runtime/src/hooks/index.ts remax-runtime/src/hooks/useQuery.ts remax-runtime/src/hooks/useNativeEffect.ts remax-runtime/src/hooks/usePageContext.ts remax-runtime/src/createPageWrapper.ts remax-runtime/src/RuntimeOptions.ts remax-runtime/src/PluginDriver.ts remax-runtime/src/propsAlias.ts remax-runtime/src/AppContainer.ts remax-runtime/src/render.ts remax-runtime/src/index.ts remax-runtime/src/nativeEffect.ts remax-runtime/src/createNativeComponent.ts remax-runtime/src/AppInstanceContext.ts remax-runtime/src/instanceId.ts remax-runtime/src/PageContext.ts remax-runtime/src/ReactPortal.ts remax-runtime/src/constants.ts remax-runtime/src/stopPullDownRefresh/index.ts remax-wechat/src/hostComponents/node.ts remax-wechat/src/hostComponents/index.ts remax-wechat/src/hostComponents/Video/index.ts remax-wechat/src/hostComponents/Video/node.ts remax-wechat/src/hostComponents/Canvas/index.ts remax-wechat/src/hostComponents/Canvas/node.ts remax-wechat/src/hostComponents/Camera/index.ts remax-wechat/src/hostComponents/Camera/node.ts remax-wechat/src/hostComponents/LivePlayer/index.ts remax-wechat/src/hostComponents/LivePlayer/node.ts remax-wechat/src/hostComponents/Editor/index.ts remax-wechat/src/hostComponents/Editor/node.ts remax-wechat/src/hostComponents/Progress/index.ts remax-wechat/src/hostComponents/Progress/node.ts remax-wechat/src/hostComponents/Input/index.ts remax-wechat/src/hostComponents/Input/node.ts remax-wechat/src/hostComponents/Map/index.ts remax-wechat/src/hostComponents/Map/node.ts remax-wechat/src/hostComponents/FunctionalPageNavigator/index.ts remax-wechat/src/hostComponents/FunctionalPageNavigator/node.ts remax-wechat/src/hostComponents/Form/index.ts remax-wechat/src/hostComponents/Form/node.ts remax-wechat/src/hostComponents/Slider/index.ts remax-wechat/src/hostComponents/Slider/node.ts remax-wechat/src/hostComponents/MovableView/index.ts remax-wechat/src/hostComponents/MovableView/node.ts remax-wechat/src/hostComponents/Icon/index.ts remax-wechat/src/hostComponents/Icon/node.ts remax-wechat/src/hostComponents/Textarea/index.ts remax-wechat/src/hostComponents/Textarea/node.ts remax-wechat/src/hostComponents/Button/index.ts remax-wechat/src/hostComponents/Button/node.ts remax-wechat/src/hostComponents/ScrollView/index.ts remax-wechat/src/hostComponents/ScrollView/node.ts remax-wechat/src/hostComponents/Switch/index.ts remax-wechat/src/hostComponents/Switch/node.ts remax-wechat/src/hostComponents/LivePusher/index.ts remax-wechat/src/hostComponents/LivePusher/node.ts remax-wechat/src/hostComponents/Swiper/index.ts remax-wechat/src/hostComponents/Swiper/node.ts remax-wechat/src/hostComponents/View/index.ts remax-wechat/src/hostComponents/View/node.ts remax-wechat/src/hostComponents/Picker/index.ts remax-wechat/src/hostComponents/Picker/node.ts remax-wechat/src/hostComponents/Checkbox/index.ts remax-wechat/src/hostComponents/Checkbox/node.ts remax-wechat/src/hostComponents/Ad/index.ts remax-wechat/src/hostComponents/Ad/node.ts remax-wechat/src/hostComponents/Image/index.ts remax-wechat/src/hostComponents/Image/node.ts remax-wechat/src/hostComponents/RichText/index.ts remax-wechat/src/hostComponents/RichText/node.ts remax-wechat/src/hostComponents/MovableArea/index.ts remax-wechat/src/hostComponents/MovableArea/node.ts remax-wechat/src/hostComponents/Radio/index.ts remax-wechat/src/hostComponents/Radio/node.ts remax-wechat/src/hostComponents/Text/index.ts remax-wechat/src/hostComponents/Text/node.ts remax-wechat/src/hostComponents/OpenData/index.ts remax-wechat/src/hostComponents/OpenData/node.ts remax-wechat/src/hostComponents/Navigator/index.ts remax-wechat/src/hostComponents/Navigator/node.ts remax-wechat/src/hostComponents/OfficialAccount/node.ts remax-wechat/src/hostComponents/OfficialAccount/index.ts remax-wechat/src/hostComponents/CoverImage/node.ts remax-wechat/src/hostComponents/CoverImage/index.ts remax-wechat/src/hostComponents/Label/node.ts remax-wechat/src/hostComponents/Label/index.ts remax-wechat/src/hostComponents/RadioGroup/node.ts remax-wechat/src/hostComponents/RadioGroup/index.ts remax-wechat/src/hostComponents/SwiperItem/node.ts remax-wechat/src/hostComponents/SwiperItem/index.ts remax-wechat/src/hostComponents/CheckboxGroup/node.ts remax-wechat/src/hostComponents/CheckboxGroup/index.ts remax-wechat/src/hostComponents/WebView/node.ts remax-wechat/src/hostComponents/WebView/index.ts remax-wechat/src/hostComponents/PickerView/node.ts remax-wechat/src/hostComponents/PickerView/index.ts remax-wechat/src/hostComponents/Audio/node.ts remax-wechat/src/hostComponents/Audio/index.ts remax-wechat/src/hostComponents/CoverView/node.ts remax-wechat/src/hostComponents/CoverView/index.ts remax-wechat/src/hostComponents/PickerViewColumn/node.ts remax-wechat/src/hostComponents/PickerViewColumn/index.ts remax-wechat/src/node/index.ts remax-ali/src/hostComponents/node.ts remax-ali/src/hostComponents/index.ts remax-ali/src/hostComponents/Canvas/node.ts remax-ali/src/hostComponents/Canvas/index.ts remax-ali/src/hostComponents/CoverImage/node.ts remax-ali/src/hostComponents/CoverImage/index.ts remax-ali/src/hostComponents/CoverView/node.ts remax-ali/src/hostComponents/CoverView/index.ts remax-ali/src/hostComponents/RadioGroup/node.ts remax-ali/src/hostComponents/RadioGroup/index.ts remax-ali/src/hostComponents/Input/node.ts remax-ali/src/hostComponents/Input/index.ts remax-ali/src/hostComponents/Progress/node.ts remax-ali/src/hostComponents/Progress/index.ts remax-ali/src/hostComponents/Map/node.ts remax-ali/src/hostComponents/Map/index.ts remax-ali/src/hostComponents/Form/node.ts remax-ali/src/hostComponents/Form/index.ts remax-ali/src/hostComponents/SwiperItem/node.ts remax-ali/src/hostComponents/SwiperItem/index.ts remax-ali/src/hostComponents/Slider/node.ts remax-ali/src/hostComponents/Slider/index.ts remax-ali/src/hostComponents/CheckboxGroup/node.ts remax-ali/src/hostComponents/CheckboxGroup/index.ts remax-ali/src/hostComponents/Radio/node.ts remax-ali/src/hostComponents/Radio/index.ts remax-ali/src/hostComponents/WebView/node.ts remax-ali/src/hostComponents/WebView/index.ts remax-ali/src/hostComponents/MovableView/node.ts remax-ali/src/hostComponents/MovableView/index.ts remax-ali/src/hostComponents/Icon/node.ts remax-ali/src/hostComponents/Icon/index.ts remax-ali/src/hostComponents/PickerView/node.ts remax-ali/src/hostComponents/PickerView/index.ts remax-ali/src/hostComponents/Lifestyle/node.ts remax-ali/src/hostComponents/Lifestyle/index.ts remax-ali/src/hostComponents/Textarea/node.ts remax-ali/src/hostComponents/Textarea/index.ts remax-ali/src/hostComponents/Button/node.ts remax-ali/src/hostComponents/Button/index.ts remax-ali/src/hostComponents/ScrollView/node.ts remax-ali/src/hostComponents/ScrollView/index.ts remax-ali/src/hostComponents/Switch/node.ts remax-ali/src/hostComponents/Switch/index.ts remax-ali/src/hostComponents/ContactButton/node.ts remax-ali/src/hostComponents/ContactButton/index.ts remax-ali/src/hostComponents/Label/node.ts remax-ali/src/hostComponents/Label/index.ts remax-ali/src/hostComponents/Swiper/node.ts remax-ali/src/hostComponents/Swiper/index.ts remax-ali/src/hostComponents/View/node.ts remax-ali/src/hostComponents/View/index.ts remax-ali/src/hostComponents/Picker/node.ts remax-ali/src/hostComponents/Picker/index.ts remax-ali/src/hostComponents/Checkbox/node.ts remax-ali/src/hostComponents/Checkbox/index.ts remax-ali/src/hostComponents/Image/node.ts remax-ali/src/hostComponents/Image/index.ts remax-ali/src/hostComponents/RichText/node.ts remax-ali/src/hostComponents/RichText/index.ts remax-ali/src/hostComponents/MovableArea/node.ts remax-ali/src/hostComponents/MovableArea/index.ts remax-ali/src/hostComponents/Video/node.ts remax-ali/src/hostComponents/Video/index.ts remax-ali/src/hostComponents/Text/node.ts remax-ali/src/hostComponents/Text/index.ts remax-ali/src/hostComponents/Navigator/node.ts remax-ali/src/hostComponents/Navigator/index.ts remax-ali/src/hostComponents/PickerViewColumn/node.ts remax-ali/src/hostComponents/PickerViewColumn/index.ts remax-ali/src/node/index.ts remax-one/src/hostComponents/Input/index.ts remax-one/src/hostComponents/Input/props/alias/index.ts remax-one/src/hostComponents/Textarea/index.ts remax-one/src/hostComponents/Textarea/props/alias.ts remax-one/src/hostComponents/Textarea/props/index.ts remax-one/src/hostComponents/index.ts remax-one/src/hostComponents/Form/index.ts remax-one/src/hostComponents/Form/props/default/index.ts remax-one/src/hostComponents/Form/props/index.ts remax-one/src/hostComponents/Image/index.ts remax-one/src/hostComponents/Image/props/default/index.ts remax-one/src/hostComponents/Image/props/index.ts remax-one/src/hostComponents/Text/index.ts remax-one/src/hostComponents/Text/props/default/index.ts remax-one/src/hostComponents/Text/props/index.ts remax-one/src/hostComponents/Navigator/index.ts remax-one/src/hostComponents/Navigator/props/default/index.ts remax-one/src/hostComponents/Navigator/props/index.ts remax-one/src/hostComponents/Button/index.ts remax-one/src/hostComponents/Button/props/default/index.ts remax-one/src/hostComponents/Button/props/alias/index.ts remax-one/src/hostComponents/View/index.ts remax-one/src/hostComponents/View/props/default/index.ts remax-one/src/hostComponents/View/props/index.ts remax-one/src/hostComponents/Label/index.ts remax-one/src/hostComponents/WebView/index.ts remax-one/src/createHostComponent.ts remax-toutiao/src/hostComponents/node.ts remax-toutiao/src/hostComponents/index.ts remax-toutiao/src/hostComponents/Input/index.ts remax-toutiao/src/hostComponents/Input/node.ts remax-toutiao/src/hostComponents/Progress/index.ts remax-toutiao/src/hostComponents/Progress/node.ts remax-toutiao/src/hostComponents/Form/index.ts remax-toutiao/src/hostComponents/Form/node.ts remax-toutiao/src/hostComponents/Slider/index.ts remax-toutiao/src/hostComponents/Slider/node.ts remax-toutiao/src/hostComponents/Video/index.ts remax-toutiao/src/hostComponents/Video/node.ts remax-toutiao/src/hostComponents/WebView/index.ts remax-toutiao/src/hostComponents/WebView/node.ts remax-toutiao/src/hostComponents/Icon/index.ts remax-toutiao/src/hostComponents/Icon/node.ts remax-toutiao/src/hostComponents/Textarea/index.ts remax-toutiao/src/hostComponents/Textarea/node.ts remax-toutiao/src/hostComponents/Button/index.ts remax-toutiao/src/hostComponents/Button/node.ts remax-toutiao/src/hostComponents/ScrollView/index.ts remax-toutiao/src/hostComponents/ScrollView/node.ts remax-toutiao/src/hostComponents/Switch/index.ts remax-toutiao/src/hostComponents/Switch/node.ts remax-toutiao/src/hostComponents/Swiper/index.ts remax-toutiao/src/hostComponents/Swiper/node.ts remax-toutiao/src/hostComponents/View/index.ts remax-toutiao/src/hostComponents/View/node.ts remax-toutiao/src/hostComponents/Picker/index.ts remax-toutiao/src/hostComponents/Picker/node.ts remax-toutiao/src/hostComponents/Checkbox/index.ts remax-toutiao/src/hostComponents/Checkbox/node.ts remax-toutiao/src/hostComponents/Image/index.ts remax-toutiao/src/hostComponents/Image/node.ts remax-toutiao/src/hostComponents/Radio/index.ts remax-toutiao/src/hostComponents/Radio/node.ts remax-toutiao/src/hostComponents/Text/index.ts remax-toutiao/src/hostComponents/Text/node.ts remax-toutiao/src/hostComponents/Navigator/index.ts remax-toutiao/src/hostComponents/Navigator/node.ts remax-toutiao/src/hostComponents/Canvas/node.ts remax-toutiao/src/hostComponents/Canvas/index.ts remax-toutiao/src/hostComponents/Label/node.ts remax-toutiao/src/hostComponents/Label/index.ts remax-toutiao/src/hostComponents/RadioGroup/node.ts remax-toutiao/src/hostComponents/RadioGroup/index.ts remax-toutiao/src/hostComponents/SwiperItem/node.ts remax-toutiao/src/hostComponents/SwiperItem/index.ts remax-toutiao/src/hostComponents/CheckboxGroup/node.ts remax-toutiao/src/hostComponents/CheckboxGroup/index.ts remax-toutiao/src/hostComponents/PickerView/node.ts remax-toutiao/src/hostComponents/PickerView/index.ts remax-toutiao/src/hostComponents/RichText/node.ts remax-toutiao/src/hostComponents/RichText/index.ts remax-toutiao/src/hostComponents/PickerViewColumn/node.ts remax-toutiao/src/hostComponents/PickerViewColumn/index.ts remax-toutiao/src/node/index.ts remax-shared/src/promisify.ts remax-shared/src/createHostComponent.ts remax-shared/src/formatDisplayName.ts remax-shared/src/path.ts remax-web/src/LoadingIcon.tsx remax-web/src/PullToRefresh.tsx

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 2 files from the diff.

@@ -20,33 +20,36 @@
Loading
20 20
  idCounter = 0;
21 21
}
22 22
23 -
const defaultData = {
24 -
  root: {
25 -
    children: [],
26 -
  },
27 -
  modalRoot: {
28 -
    children: [],
29 -
  },
30 -
};
31 -
32 -
const defaultLifecycleCallback: any = {};
33 -
34 23
export default function createPageConfig(Page: React.ComponentType<any>, name: string) {
35 24
  const app = getApp() as any;
36 25
37 26
  const config: any = {
38 -
    data: defaultData,
27 +
    data: {
28 +
      root: {
29 +
        children: [],
30 +
      },
31 +
      modalRoot: {
32 +
        children: [],
33 +
      },
34 +
    },
39 35
40 36
    wrapperRef: React.createRef<any>(),
41 37
42 -
    lifecycleCallback: defaultLifecycleCallback,
38 +
    lifecycleCallback: {},
43 39
44 40
    onLoad(this: any, query: any) {
45 41
      const PageWrapper = createPageWrapper(Page, name);
46 42
      this.pageId = generatePageId();
47 43
48 -
      this.lifecycleCallback = defaultLifecycleCallback;
49 -
      this.data = defaultData;
44 +
      this.lifecycleCallback = {};
45 +
      this.data = {
46 +
        root: {
47 +
          children: [],
48 +
        },
49 +
        modalRoot: {
50 +
          children: [],
51 +
        },
52 +
      };
50 53
51 54
      this.query = query;
52 55
      this.container = new Container(this, 'root');
@@ -114,25 +117,25 @@
Loading
114 117
    events: {
115 118
      // 页面返回时触发
116 119
      onBack(this: any, e: any) {
117 -
        return config.callLifecycle(Lifecycle.back, e);
120 +
        return this.callLifecycle(Lifecycle.back, e);
118 121
      },
119 122
120 123
      // 键盘高度变化时触发
121 124
      onKeyboardHeight(this: any, e: any) {
122 -
        return config.callLifecycle(Lifecycle.keyboardHeight, e);
125 +
        return this.callLifecycle(Lifecycle.keyboardHeight, e);
123 126
      },
124 127
125 128
      onTabItemTap(this: any, e: any) {
126 -
        return config.callLifecycle(Lifecycle.tabItemTap, e);
129 +
        return this.callLifecycle(Lifecycle.tabItemTap, e);
127 130
      },
128 131
129 132
      // 点击但切换tabItem前触发
130 133
      beforeTabItemTap(this: any) {
131 -
        return config.callLifecycle(Lifecycle.beforeTabItemTap);
134 +
        return this.callLifecycle(Lifecycle.beforeTabItemTap);
132 135
      },
133 136
134 137
      onResize(this: any, e: any) {
135 -
        return config.callLifecycle(Lifecycle.resize, e);
138 +
        return this.callLifecycle(Lifecycle.resize, e);
136 139
      },
137 140
    },
138 141

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
packages -<.01% 95.37%
Project Totals (350 files) 95.37%
Loading