1

Trying to make deep linking for React Native Web work. Browsed many articles and finally found a solution proposed for the exact problem faced in this link whch doesn't work for me.

Expo documentation says use

const prefix = Linking.makeUrl('/')

and set the prefix in the AppNavigator.

Wondering how can I point to my react native web app when use clicks a link. The problem is Linking.makeUrl('/') returns exp://localhost:19006/ on my laptop. As browser wouldn't recognize exp as scheme is unable to open my URL.

I tried setting the scheme to https in app.json but still Linking.makeUrl('/') returns the scheme as expo.

In my app when user clicks on static html page which I load in the app I want to route back to my app. As I am unable to get right scheme for React Native Web using Expo unable to proceed further.

Thank you.

Attaching the code provided in the link.

import React from 'react'
import { createSwitchNavigator } from '@react-navigation/core'
import { createBrowserApp } from "@react-navigation/web"
import { Linking } from 'expo'

const prefix = Linking.makeUrl('/')
const AppNavigator = createBrowserApp(createSwitchNavigator({
  Landing: {
    screen: LandingScreen,
    path: '/'
  },
  Login: {
    screen: LoginScreen,
    path: 'login'
}
}, {
  initialRouteName: 'Landing',
  backBehavior: 'history'
}))
export default () => <AppNavigator uriPrefix={prefix} />
coolcake
  • 2,917
  • 8
  • 42
  • 57

1 Answers1

0

Try : const prefix = Linking.createURL('/');

  • 1
    While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Ahmet Emre Kilinc Oct 28 '21 at 20:09