useLinking Help!

Please provide the following:

  1. SDK Version: 37
  2. Platforms(Android/iOS/web/all): Web

Try to configure deep-linking on the web. The URL looks good: http://localhost:19006/drop/1, but the “Drops” screen is loading and not the “Drop” screen. Any ideas why?

import { useLinking } from '@react-navigation/native';
import { Linking } from 'expo';

export default function(containerRef) {
  return useLinking(containerRef, {
    prefixes: [Linking.makeUrl('/')],
    config: {
      Root: {
        path: 'root',
        screens:{
          Main: {
            path: 'main',
            screens: {
              Home: {
                path: 'home',
                screens: {
                  Drops: 'drops',
                  Drop: 'drop/:counter'
                }
              },
              Search: 'search',
            },
          }
        }
      }
    },
  });
}

Can you provide the initialState object created by parsing that link?

1 Like

It never gets to the Drop Screen, instead it goes to the initialRouteName under the Home Screen.

routes: Array(1)
	0:
	name: "Root"
	state:
		routes: Array(1)
		0:
			name: "Main"
			state:
				routes: Array(1)
				0:
				name: "Home"
				state:
					routes: Array(1)
					0:
					name: "Drop"
					params:
						counter: "3987"

I fixed it. I wasn’t waiting for the initialNavigationState before rendering.

The problem I’m having now is the root won’t load: http://localhost:19006/. When loading the root the initialState is undefined.

Did you use it somehow like this: https://github.com/react-navigation/react-navigation/blob/master/example/src/index.tsx#L161?

Many thanks for that complete information!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.