skip to Main Content

I tried using react-router dom but it is giving me error. Can someone please help me resolving this? Here is the code

code

And I am also enclosing the error which i am getting

error

When i go to the source, I am getting issue in browser router definition

error in browser router

I tried using react-router-dom but it’s giving me error

3

Answers


  1. 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>
    }
    
    Login or Signup to reply.
  2. It’s an error from some other component in your code.

    Happens when you try to use react hooks outside function body.

    Login or Signup to reply.
  3. 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>
     );
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search