markdalgleish / redial

Universal data fetching and route lifecycle management for React etc.
1.1k stars 42 forks source link

Good way to prevent fetching when route changes? #30

Closed johanneslumpe closed 8 years ago

johanneslumpe commented 8 years ago

I'm trying to transition an app to use redial but I have the need to prevent possible refetches based on conditions involving comparison of the previous and next params. My current custom implementation uses component hooks and works much like a resolver (with multi-pass rendering on the server).

Given a route /something/:id/:segment I want to prevent data fetching if :segment changes and allow it if :id changes. @markdalgleish Do you have any pointers how to make this work? I feel that I have to use something like redux-react-router to gain access to the previous params in the match which gets executed in history.listen. Would love to hear your thoughts on this and maybe a different approach if you happen to have one.

johanneslumpe commented 8 years ago

I just figured it might be as easy as storing parts of renderProps in a variable outside of history.listen and then pass those as locals as well.