react-nativereact-routerreact-router-domreact-proptypes

React-router-native: Undefined is not an object (evaluating '_react.PropTypes.func')


i have created a project with react-native. When i install react-router with the command

 npm install react-router-native

I have the following error: https://prnt.sc/6nzME4AUzGi1

My problem is that i am not using

 react.PropTypes.func 

in my program but this error indicates in node modules.

My code is here:

 import { NativeRouter } from "react-router-native";

 const App = () => {
  return (
   <>
     <NativeRouter>
        <Main/>
     </NativeRouter>
    <RepositoryList />
  </>
 )
}; 

My other file:

  <Routes>
    <Route path="/" element={<RepositoryList />} exact />
    <Route path="/signIn" element={<SignIn />} exact />
  </Routes>

When i am not using

 react-router-native

my program works fine. There is a problem with my code or is something else?


Solution

  • Looks like you've a bunch of much older versions of react-router and history installed.

    react-router-natve@5.3.2 is installed, but react-router is a much older v2 version (that also isn't compatible with React 17). Based on the Route component API/syntax used you want react-router@6 and react-router-native@6 installed.

    You'll likely want to uninstall those, then install the specific version of react-router and react-router-native.

    Uninstall/install react-router and react-router-native v6:

    npm install --save react-router@6 react-router-native@6