Passing props between views

Hello,

I setup two routers in my application:

  • </Home> → /
  • </Search> → /search

At </Home>, the application has a section for select a category and redirect the user to </Search> passing the search filter related to category in the url params.

I implemented this simply updating the current URL.

The change between views works fine, but looks like </InstantSearch> component is not detecting the new props received. I need to reload for see the expected result.

https://d26dzxoao6i3hh.cloudfront.net/items/0s1m0I1u0C0m1v2C340e/Screen%20Recording%202017-06-22%20at%2006.02%20pm.gif?v=c970ac07

Probably I’m doing something bad. You can see it on live at https://windtoday.co.

Any help is welcome, source code is available :smile:

Hi @josefrancisco.verdu,

Did you update the search state (via setState) when navigating to your new route?

The usual flow is => you navigate to the new route, you parse the url to reconstruct the search state and you do a setState with this new search state.

Because you’ll pass the search state to <InstantSearch/>, it will trigger a new rerender that should perform a new query.

I’m not updating setState, how to do that?

I suppose I need to do that at this point

https://github.com/windtoday/windtoday-app/blob/master/src/app/App/index.js#L109

oh, I found the way following your words!

Basically set the new state in the transition of the view :smile:

Preview: https://deploy-preview-254–windtoday-app.netlify.com/#/

But now, I don’t know why, pagination based in URL is not working :thinking:

https://deploy-preview-254–windtoday-app.netlify.com/#/search?page=3

Can you indicate me the flow you’re doing to see that?

No problem @marielaure.thuret, I fixed that, finally.

It was a problem related with use mutliple createConnectors an manipulate hits :thumbsup: