-
Notifications
You must be signed in to change notification settings - Fork 9
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
Dynamic routing validation #16
Comments
Hello! Do I understand you correctly that you want a way to manage when a hook fails for some reason, like when doing a request to an API, and then use the I don't think we can do this given how React Router works. A pattern I have used personally in projects is to render another component when this happens. Example @provideHooks({
fetch: ({ params: { id }, setProps }) =>
fetch(`/api/items/${id}`)
.then(response => response.json())
.then(item => setProps({ item }))
.catch(error => setProps({ error }))
})
export default class ItemPage extends Component {
render() {
if (this.props.error) {
return <NotFoundPage />;
}
return <Item item={this.props.item} />;
}
} If the application is using Redux I often make the application wrapper connect to the store and manage errors in a central place instead for a specific page. |
Hi, @dlmr. I use this way too, but I hope we can find universal solution to make DRY our projects and don't repeat this code
|
I very open for suggestions on how this API could look/function. 🙂 My personal solution as I mention above is to handle this in the root component with the help of Redux in complicated applications. |
Hi! Thank you for this great library!
I'm looking for a solution for displaying 404 error page without a redirect. I think It will be great If we can abort a matched route and find next one.
Example:
So, can we modify the library to do this?
The text was updated successfully, but these errors were encountered: