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

Commit

Permalink
fix: 修复部分 App 生命周期不生效的问题 (#898)
Browse files Browse the repository at this point in the history
fix #895
  • Loading branch information
yesmeck authored May 6, 2020
1 parent 1d3ffec commit e6c6bf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,11 @@ function createAppConfig(App) {
_container: new _AppContainer__WEBPACK_IMPORTED_MODULE_3__["default"](_this),
_pages: [],
_instance: react__WEBPACK_IMPORTED_MODULE_1__["createRef"](),
onLaunch: function onLaunch(options) {
this._render();

return this.callLifecycle(_lifecycle__WEBPACK_IMPORTED_MODULE_5__["AppLifecycle"].launch, options);
},
callLifecycle: function callLifecycle(lifecycle) {
var _a;

Expand Down Expand Up @@ -1780,11 +1785,6 @@ function createAppConfig(App) {
}
};
var lifecycleEvent = {
onLaunch: function onLaunch(options) {
this._render();

return this.callLifecycle(_lifecycle__WEBPACK_IMPORTED_MODULE_5__["AppLifecycle"].launch, options);
},
onShow: function onShow(options) {
return this.callLifecycle(_lifecycle__WEBPACK_IMPORTED_MODULE_5__["AppLifecycle"].show, options);
},
Expand Down
12 changes: 1 addition & 11 deletions packages/remax-cli/src/build/babel/appEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ export default (entry: string) => {
return;
}

const parentNode = path.parentPath.node;

if (t.isCallExpression(parentNode) && (parentNode.callee as any)?.name === '_defineProperty') {
appEvents.set(entry, appEvents.get(entry)?.add(node.value) ?? new Set([node.value]));
}
appEvents.set(entry, appEvents.get(entry)?.add(node.value) ?? new Set([node.value]));
},
Identifier: (path: NodePath<t.Identifier>) => {
if (skip) {
Expand All @@ -43,12 +39,6 @@ export default (entry: string) => {
return;
}

// 非函数定义不处理
// 非函数定义不处理
if (!t.isFunctionExpression(path.parentPath.node)) {
return;
}

appEvents.set(entry, appEvents.get(entry)?.add(node.name) ?? new Set([node.name]));
},
},
Expand Down
12 changes: 6 additions & 6 deletions packages/remax-runtime/src/createAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export default function createAppConfig(this: any, App: any) {

_instance: React.createRef<any>(),

onLaunch(options: any) {
this._render();

return this.callLifecycle(AppLifecycle.launch, options);
},

callLifecycle(lifecycle: AppLifecycle, ...args: any[]) {
const callbacks = AppInstanceContext.lifecycleCallback[lifecycle] || [];
let result;
Expand Down Expand Up @@ -67,12 +73,6 @@ export default function createAppConfig(this: any, App: any) {
};

const lifecycleEvent: any = {
onLaunch(options: any) {
this._render();

return this.callLifecycle(AppLifecycle.launch, options);
},

onShow(options: any) {
return this.callLifecycle(AppLifecycle.show, options);
},
Expand Down

1 comment on commit e6c6bf1

@vercel
Copy link

@vercel vercel bot commented on e6c6bf1 May 6, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.