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

Commit

Permalink
fix: 修复 onUnload 事件不触发的问题 (#1324)
Browse files Browse the repository at this point in the history
* fix(toutiao): view props type

* fix(toutiao): input type 类型

* fix(toutiao): type check

* fix: 修复 onUnload 事件未触发问题

* test: update lifecycle cases
  • Loading branch information
noyobo committed Oct 13, 2020
1 parent 41c5e10 commit 5c53ed8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions docs/guide/advanced/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default options => {
#### 参数

- `params`
- `config` - Remax 的构建配置。
- `config` - Remax 的构建配置。

```js
{
Expand All @@ -70,15 +70,14 @@ export default options => {
}
```


### onAppConfig

修改应用配置,注意跟运行时 hook `onAppConfig` 的区别,这个 hook 修改的是 `app.json`

#### 参数

- `params`
- `config` - `app.json` 配置。
- `config` - `app.json` 配置。

```js
{
Expand Down
2 changes: 1 addition & 1 deletion e2e/mini/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module.exports = {
debug: true,
command: 'http-server --cors --port=8888 -s',
port: 8888,
launchTimeout: 60000
launchTimeout: 60000,
},
};
4 changes: 2 additions & 2 deletions packages/remax-plugin-devtools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ module.exports = () => ({
]);
},
registerRuntimePlugin() {
return require.resolve('./lib/runtime')
}
return require.resolve('./lib/runtime');
},
});
8 changes: 4 additions & 4 deletions packages/remax-runtime/src/__tests__/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('page', () => {
usePageEvent('onLoad', () => {
log.push('useLoad');
});
usePageEvent('unload', () => {
usePageEvent('onUnload', () => {
log.push('useUnload');
});
usePageEvent('onReady', () => {
Expand Down Expand Up @@ -258,8 +258,8 @@ describe('page', () => {
log.push('onLoad');
}

unload() {
log.push('unload');
onUnload() {
log.push('onUnload');
}

onShow() {
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('page', () => {
'onTabItemTap',
'onResize',
'onResize',
'unload',
'onUnload',
'componentWillUnmount',
]);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/remax-runtime/src/lifecycle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ export enum AppLifecycle {
}

export function lifeCycleName(name: string): Lifecycle {
if (name.startsWith('before') || name === 'unload') {
if (name.startsWith('before')) {
return name as Lifecycle;
}
return lowercase(name.slice(2)) as Lifecycle;
}

export function callbackName(name: string) {
if (name.startsWith('before') || name === 'unload') {
if (name.startsWith('before')) {
return name;
}

Expand Down

1 comment on commit 5c53ed8

@vercel
Copy link

@vercel vercel bot commented on 5c53ed8 Oct 13, 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.