3

I am working with react native web, where @react-navigation is used for navigation. I am using linking so that users can navigate using the URL.

my linking configuration looks like

const linking = {
  prefixes: [],
  config: {
    screens: {
      Home: '',
      Profile: 'profile',
      Settings: 'settings',
      NotFound: '*',
    },
  },
};

The problem is I would like to pass a parameter using # in the URL. For an example, localhost:19006/profile#address or localhost:19006/profile#about But when I try the above URL, react-navigation automatically removes #address / #about from the URL.

I went through https://reactnavigation.org/docs/configuring-links/

I can pass the parameter like localhost:19006/profile?sec=address easily, But I want to use # in the URL.

Is there any way to use # in the URL?

Note I am using the following libraries

"@react-navigation/native": "^6.0.10",
"@react-navigation/stack": "^6.2.1",
"react-native": "0.67.3",
"react-native-web": "^0.17.7",
Shaon Debnath
  • 95
  • 2
  • 10

1 Answers1

2

you need to import Linking from the react native.

import {Linking} from 'react-native

and whenever you need to open a URL with a click event you can code below.

Linking.openURL( "Your Link");

Might be it helpful to you.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Ankit Vora
  • 568
  • 2
  • 12