Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 | 4 |
import { useLayoutEffect, useContext } from 'react'; |
2 | 4 |
import { registerLifecycle, Callback, lifeCycleName } from '../lifecycle'; |
3 | 4 |
import PageContext from '../PageContext'; |
4 | 4 |
import AppInstanceContext from '../AppInstanceContext'; |
5 |
|
|
6 |
/**
|
|
7 |
* Page Hooks
|
|
8 |
*/
|
|
9 |
|
|
10 | 4 |
export function usePageInstance() { |
11 |
return useContext(PageContext)?.page; |
|
12 |
}
|
|
13 |
|
|
14 | 4 |
export { default as useNativeEffect } from './useNativeEffect'; |
15 | 4 |
export { default as useQuery } from './useQuery'; |
16 |
|
|
17 | 4 |
export function usePageEvent(eventName: string, callback: Callback) { |
18 |
const pageInstance = useContext(PageContext)?.page; |
|
19 | 4 |
const lifeCycle = lifeCycleName(eventName); |
20 | 4 |
useLayoutEffect(() => { |
21 | 4 |
return registerLifecycle(pageInstance, lifeCycle, callback); |
22 |
});
|
|
23 |
}
|
|
24 |
|
|
25 |
/**
|
|
26 |
* App Hooks
|
|
27 |
*/
|
|
28 |
|
|
29 | 4 |
export function useAppEvent(eventName: string, callback: Callback) { |
30 | 4 |
const lifeCycle = lifeCycleName(eventName); |
31 | 4 |
useLayoutEffect(() => { |
32 | 4 |
return registerLifecycle(AppInstanceContext, lifeCycle, callback); |
33 |
});
|
|
34 |
}
|
Read our documentation on viewing source code .