This repository has been archived by the owner on Feb 8, 2020. It is now read-only.
generated from satya164/typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as React from 'react'; | ||
import { | ||
NavigationContainer, | ||
NavigationContainerProps, | ||
NavigationContainerRef, | ||
} from '@react-navigation/core'; | ||
import useBackButton from './useBackButton'; | ||
|
||
/** | ||
* Container component which holds the navigation state | ||
* designed for mobile apps. | ||
* This should be rendered at the root wrapping the whole app. | ||
* | ||
* @param props.initialState Initial state object for the navigation tree. | ||
* @param props.onStateChange Callback which is called with the latest navigation state when it changes. | ||
* @param props.children Child elements to render the content. | ||
* @param props.ref Ref object which refers to the navigation object containing helper methods. | ||
*/ | ||
|
||
const NativeContainer = React.forwardRef(function NativeContainer( | ||
props: NavigationContainerProps, | ||
ref: React.Ref<NavigationContainerRef> | ||
) { | ||
const refContainer = React.useRef<NavigationContainerRef>(null); | ||
|
||
useBackButton(refContainer); | ||
React.useImperativeHandle(ref, () => refContainer.current); | ||
|
||
return ( | ||
<NavigationContainer | ||
{...props} | ||
ref={refContainer} | ||
children={props.children} | ||
/> | ||
); | ||
}); | ||
|
||
export default NativeContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as useBackButton } from './useBackButton'; | ||
export { default as useLinking } from './useLinking'; | ||
export { default as NativeContainer } from './NativeContainer'; |