0

I have a simple router which is possible via the @reach/router module

<Router>
   <Home path="/" />
   <Resume path="resume" />
</Router>

When someone enter the full URL ending in "/resume" I would like the resume component to show up and I thought this happens automatically via @reach/router but does not seem to be the case.

any strategies to making this work?

iJK
  • 4,655
  • 12
  • 63
  • 95
  • It works. Check [sandbox](https://codesandbox.io/s/so-reach-router-s3d7f?file=/src/index.js). Not sure why it doesn't work for you. – Ajeet Shah Jun 10 '20 at 01:01
  • @AjeetShah Yes, it does work locally but after hosting on netlify it does not seem to work. – iJK Jun 10 '20 at 01:23
  • 1
    Does it show error 404 not found on netlify? If yes, you may need this strategy: https://stackoverflow.com/a/62050700/2873538 – Ajeet Shah Jun 10 '20 at 01:26

1 Answers1

-1

You should be using the <Route /> component to do this.

import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter as Router, Route } from "react-router-dom";

render (
  <Router>
    <Route path="/" component={Home} />
    <Route path="/resume" component={Resume} />
  </Router>
);

For reference, here are the docs. react-router

  • 1
    OP is not using react-router but [@reach/router](https://github.com/reach/router). – Ajeet Shah Jun 10 '20 at 01:02
  • @Justin Yes, I am not using react-router and it does seem to work locally but not after I host it on Netlify – iJK Jun 10 '20 at 01:24