Skip to content
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

Is there a way to pass params to the router? #103

Open
fermartz opened this issue Sep 20, 2018 · 2 comments
Open

Is there a way to pass params to the router? #103

fermartz opened this issue Sep 20, 2018 · 2 comments

Comments

@fermartz
Copy link

Hey guys,

In few words I'm trying to create a page where I will display related topics. Imagine when you have a blog and you have tags and categories. If you click a tag the system will take you to search results.

This is how I would do it in a 'normal' react app but I'm a bit confused about how to do it in X0 since the system is creating the routes 'automagically' for us.

<Route path = "search/:id" component={Search}></Route>

Any help would be greatly appreciated!!!

@jxnblk
Copy link
Member

jxnblk commented Sep 22, 2018

It's undocumented and experimental, but you can return a path in getInitialProps as seen here: https://github.com/c8r/blog/blob/master/pages/post.js#L20 – You'll also want to return a subroutes routes array in order for the static build to know what to export

@fermartz
Copy link
Author

Thanks Brent!

I'll take a look and try to implement it in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants