I tried using react-router dom but it is giving me error. Can someone please help me resolving this? Here is the code
And I am also enclosing the error which i am getting
When i go to the source, I am getting issue in browser router definition
I tried using react-router-dom but it’s giving me error
3
this looks like an error from either the HomePage component or the ApplicationForm one.
It looks like you are using a react hook outside the body of the function component.
Example can be
some hook here such as useRef() const someFunction = () =>{ return <h6>Hello</h6> }
It’s an error from some other component in your code.
Happens when you try to use react hooks outside function body.
Set up your index.js as follows:
ReactDOM.render( <React.StrictMode> <BrowserRouter> <Routes> <Route path="/" element={ <App /> }> </Route> </Routes> </BrowserRouter> </React.StrictMode> ,document.getElementById('root') );
Then remove BrowserRouter from App.js file:
const App = () => { return ( <div className="App"> <Routes> <Route path="/" element={<HomePage />} /> <Route path="/application" element={<ApplicationForm/>} /> </Routes> </div> ); };
Click here to cancel reply.
3
Answers
this looks like an error from either the HomePage component or the ApplicationForm one.
It looks like you are using a react hook outside the body of the function component.
Example can be
It’s an error from some other component in your code.
Happens when you try to use react hooks outside function body.
Set up your index.js as follows:
Then remove BrowserRouter from App.js file: