-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate using Reach Router #5656
Comments
Hey @m-allanson , I would love to help on this issue. I am new to Gatsby but I know React and React Router.
Thanks! |
This recent issue talks about accessibility. And here is Reach Router’s section on accessibility. |
@ryanditjia Thanks for the information. Can you also tell "What metrics do we need to consider while evaluating the tradeoffs". |
I've been chatting with @ryanflorence some about this change and it seems pretty compelling. It's a mostly drop-in replacement which fixes our current accessibility problems + reduces the size of our routing layer fairly significantly. Relative link support also sounds nice as it'll allow people to build more mini-apps that they can just drop into Gatsby sites wherever as needed. |
Update on this! @ryanflorence and I are pairing tomorrow to work on getting @react/router in. |
@KyleAMathews People just figured out how to work around lack of layout components on this issue: #6127 This change now breaks that. Not being able to tell wether something is a push or a pop will also affect people trying to do animations based on routing. There are some compelling reasons for making this change, but the number of breaking changes for V2 is getting to be a bit much. I also have a situation where I need to listen for history changes which I can't see how to do with this |
@DylanVann Hey! Agree that things have been a bit rough the past couple of days. But it's very fixable. Could you file an issue w/ more details about what you're seeing + a reproduction site showing where things are broken? We can look at things and @ryanflorence has some time to help make fixes to @reach/router where necessary. |
I can add push/pop, but I'd love to know how people use them with animations, since with "pop" you don't know if it's forward or backward or even how far forward or backward in the stack you went. I suspect those animations are broken. You probably ought to rely on Anyway, we can add As for listening to history for changes, are you sure you can't do the same thing with components? <Location>
{({ location }) => (
<ThingThatDoesStuffWith location={location}/>
)}
</Location>
class ThingThatDoesStuffWithLocation extends React.Component {
componentDidUpdate(prevProps) {
if (prevProps.location !== this.props.location) {
// do the thing
}
}
render() {
return null
}
} But indeed, you can listen to the history if you'd like to: import { globalHistory } from '@reach/router/lib/history'
globalHistory.listen(() => {
// do your thing
}) |
@KyleAMathews @ryanflorence Thanks so much for the help. As far as specifics the three things I'm trying to do right now are:
For animations I vaguely remember using action types with |
@DylanVann @KyleAMathews @ryanflorence I've been trying to implement component-specific page transitions the past couple days and wasn't able to get it working with Reach Router. Adding a gatsby-browser.js at examples/using-page-transitions:const getUserConfirmation = (pathname, callback) => {
const event = new CustomEvent(historyExitingEventType, { detail: { pathname } })
window.dispatchEvent(event)
setTimeout(() => {
callback(true)
}, timeout)
} ...which is not possible anymore. I'm not sure if something like this would go against the accessibility concern of Reach Router, but I think this should be possible in Gatsby. Any thoughts? EDIT: Finally found a way using React Pose, here's a great guide. I implemented this in one of my starters. |
Hey, I've been using connected-react-router before to dispatch redux actions like |
Summary
Gatsby uses React Router under the hood. Reach Router is a new DOM-based router for React with accessibility built in. Influenced by React Router and built by Ryan Florence: https://reach.tech/router/accessibility
Investigate the tradeoffs involved in swapping out React Router for Reach Router.
Motivation
Adding 'accessiblity by default' is a win for developers and site visitors. As a bonus it looks like Reach Router has a smaller bundle size compared to React Router.
The text was updated successfully, but these errors were encountered: