Closed tristan-orourke closed 2 years ago
Just from a cursory search, I wonder if it has to do with this - announcing page navigations for screen readers? https://estevanmaito.me/blog/accessible-navigation-using-react-router
What I recall of reach-router and react-router differences and fork/merge:
https://blog.logrocket.com/react-router-v6-future-reach-router/
In May of 2019, Ryan Florence, co-creator of React Router and Reach Router, announced the impending release of a new version of React Router that takes advantage of React’s Hooks API. He also stated that React Router would be the surviving project, while Reach Router will continue to receive support in the form of bug fixes.
Both reach and react-router now handle focus management in much more accessible ways, for both client-side and server-size.
Number of issues mentioning accessibility keywords:
Open questions:
Still need to read this more deeply, but mentions (circa 2019) that server-side rendering is highly recommended for accessibility in govuk react sites: https://github.com/govuk-react/govuk-react/blob/main/ACCESSIBILITY.md (note that the references to the "service standard" points 12 & 13 are for the 2019 version
Via React Router v6 in Three Minutes (Feb 2020):
https://twitter.com/mjackson/status/1229156979714605056
what was the biggest factor that led to this change [in bundle size down 70%]?
A couple of things:
- dropping support for anything older than IE11
- dropping support for React < 16.8
- using Google Closure Compiler
- writing better code 😅
Not specifically a11y, but here's another downside of not having react-router.
I'm finding it hard to see how component state is exercised for stories whose components contain logic based on location.pathname
. As it stands, we'd need to make pathname or location optionally injectable into each component (if it's checking pathname to determine its render state). This is due to how we're implementing universal-router without any context to override the navigator
/history
object we get from createBrowserHistory():
For comparison of things possible with react-router, this is what using <MemoryRouter>
in a story looks like:
https://chestozo.medium.com/how-to-mock-location-inside-storybook-stories-76a7c0705354
Since our useLocation()
hook hardcodes the use of createBrowserHistory()
, we can't easily use createMemoryHistory()
like react-router does. I believe this is what is offered by the extra layer of <Router>
, which adds context that stores this kind of stuff, and can be modified.
(I tried making my own <RouterContainer>
that defaults a navigator
prop to be a createBrowserHistory()
object stored in context. This could be overridden in stories via <RouterContainer navigator={createMemoryHistory()}>
. But it started to get hairy in common/src/helpers/helpers/router.tsx
and so I backed out before hitting success. I needed the new RouterContext
from admin side of app, but that can't be imported in common. Wasn't sure it felt like the right approach when react-router offers this already.)
The answer to the spike seems to be YES
Description
We're doing frontend routing with a custom hook and UniversalRouter. Are there any major features, especially around accessibility, that React Router offers that we are currently missing?
Timeboxed to 1-2 hours.