Files
react-navigation/packages/native/README.md
2019-12-11 17:44:21 +01:00

49 lines
839 B
Markdown

# `@react-navigation/native`
React Native integration for React Navigation
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/native
```
## Usage
```js
const ref = React.useRef();
useBackButton(ref);
const { getInitialState } = useLinking(ref, {
prefixes: ['https://myapp.com', 'myapp://'],
});
const [isReady, setIsReady] = React.useState(false);
const [initialState, setInitialState] = React.useState();
React.useEffect(() => {
getInitialState()
.catch(() => {})
.then(state => {
if (state !== undefined) {
setInitialState(state);
}
setIsReady(true);
});
}, [getInitialState]);
if (!isReady) {
return null;
}
return (
<NavigationContainer initialState={initialState} ref={ref}>
{/* content */}
</NavigationContainer>
);
```