0

I am trying to send status 404 but I am not able to send it while using the following code. I am using version 5 for react-router-dom. I have tried various ways but its still not showing the correct status and shows 200 for every URL.

  return (
    <Router>
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to the Pokédex</h1>
        </header>
        <br />
        <br />
        <div className="App-body">
          <h2>Information about Pokémon, Berries and Machine</h2>
          <p>This website will tell you about how pokemon works.</p>
          <Link className="showlink" to="/pokemon/page/0">
            Pokémon
          </Link>
          <Link className="showlink" to="/berries/page/0">
            Berries
          </Link>
          <Link className="showlink" to="/machines/page/0">
            Machines
          </Link>
          <Switch>
            <Route exact path="/" />
            <Route
              exact
              path="/pokemon/page/:page"
              exact
              component={PokemonList}
            />
            <Route
              exact
              path="/berries/page/:page"
              exact
              component={BerriesList}
            />
            <Route
              exact
              path="/machines/page/:page"
              exact
              component={MachineList}
            />
            <Route exact path="/pokemon/:id" exact component={Pokemon} />
            <Route exact path="/berries/:id" exact component={Berries} />
            <Route exact path="/machines/:id" exact component={Machines} />
            <Route path="*" status={404}>
              <PageNotFound />
            </Route>
          </Switch>
        </div>
      </div>
    </Router>
  );
}
Kunj
  • 11
  • 5

0 Answers0