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

Commit

Permalink
fix: 修复 onReady 回调
Browse files Browse the repository at this point in the history
fix: #203
  • Loading branch information
yesmeck committed Sep 7, 2019
1 parent 28d5306 commit f6e276d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/remax/src/createPageConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export default function createPageConfig(Page: React.ComponentType<any>) {
return this.callLifecycle(Lifecycle.hide);
},

onReady() {
return this.callLifecycle(Lifecycle.ready);
},

onPullDownRefresh(e: any) {
return this.callLifecycle(Lifecycle.pullDownRefresh, e);
},
Expand Down
6 changes: 6 additions & 0 deletions packages/remax/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export function useShow(callback: Callback) {
});
}

export function useReady(callback: Callback) {
useLayoutEffect(() => {
return registerLifecycle(Lifecycle.ready, callback);
});
}

export function useHide(callback: Callback) {
useLayoutEffect(() => {
return registerLifecycle(Lifecycle.hide, callback);
Expand Down
1 change: 1 addition & 0 deletions packages/remax/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Callback = (...args: any[]) => any;
export enum Lifecycle {
show = 'show',
hide = 'hide',
ready = 'ready',
pullDownRefresh = 'pullDownRefresh',
reachBottom = 'reachBottom',
pageScroll = 'pageScroll',
Expand Down

0 comments on commit f6e276d

Please sign in to comment.