Last active
April 12, 2020 17:28
-
-
Save imjakechapman/82b37477db348fa6af828f111c1dc0b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // V5 | |
| <Router> | |
| <Switch> | |
| <Route path="/one" component={ViewOne} /> | |
| <Route path="/two" component={ViewTwo} /> | |
| <Route path="/three" component={ViewThree} /> | |
| <Route render={() => <Redirect to="/one" />} /> | |
| </Switch> | |
| </Router> | |
| // V6 | |
| <Router> | |
| <Routes> | |
| <Route path="/one" element={<ViewOne />} /> | |
| <Route path="/two" element={<ViewTwo />} /> | |
| <Route path="/three" element={<ViewThree />} /> | |
| <???> | |
| </Routes> | |
| </Router> | |
| // Possible new way of handling | |
| <Router> | |
| <Routes> | |
| <Route path="/one" element={<ViewOne />} /> | |
| <Route path="/two" element={<ViewTwo />} /> | |
| <Route path="/three" element={<ViewThree />} /> | |
| <Route path="*" element={<SelfRedirect path="/one" />} /> | |
| </Routes> | |
| </Router> | |
| const SelfRedirect = ({ path }) => { | |
| let navigate = useNavigate(); | |
| useEffect(() => { | |
| navigate(path); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment