Files
react-navigation/packages/native
satyajit.happy 849d952703 feat: make deep link handling more flexible
This adds ability to specify a custom config to control how to convert between state and path.

Example:

```js
{
  Chat: {
    path: 'chat/:author/:id',
    parse: { id: Number }
  }
}
```

The above config can parse a path matching the provided pattern: `chat/jane/42` to a valid state:

```js
{
  routes: [
    {
      name: 'Chat',
      params: { author: 'jane', id: 42 },
    },
  ],
}
```

This makes it much easier to control the parsing without having to specify a custom function.
2019-09-16 13:20:19 +02:00
..
2019-08-31 23:23:10 +02:00
2019-08-22 04:30:58 +05:30
2019-08-21 14:27:07 +05:30

@react-navigation/native

React Native integration for React Navigation

Installation

Open a Terminal in your project's folder and run,

yarn add @react-navigation/core @react-navigation/native

Usage

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>
);