4Catalyzer / found

Extensible route-based routing for React applications
https://4catalyzer.github.io/found/
MIT License
794 stars 55 forks source link

Migration instructions from react-router@3 #40

Open mistadikay opened 7 years ago

mistadikay commented 7 years ago

Hey, great project!

We use react-router@3 at the moment, but not really sure if migrating to @4 is going to happen any time soon, if ever. So, found looks like a great alternative as soon as some migration instructions from react-router will be available — I'm sure lots of people will appreciate that. Thanks

taion commented 7 years ago

Good idea. For now, the capsule summary is:

oyeanuj commented 7 years ago

@taion Thanks for the summary here! For my own understanding, I'd love to know the better the motivation, and comparison (of philosophy, approach or pros/cons) of Found and RR(2/3) and RR4? It would really help make an informed choice for a bunch of us who are coming from RR and in midst of figuring out which library to move forward with.

As someone else said on a different thread, thanks for all your work on RR and putting this library out :)

taion commented 7 years ago

See https://medium.com/@taion/react-routing-and-data-fetching-ec519428135c.

idolize commented 7 years ago

@taion Why the removal of onEnter and onLeave? I can see how the introduction of getData and render reduces the need for such explicit hooks, but I can still imagine some use cases for them (i.e. triggering an action to reset some redux state when the user leaves a given route).

taion commented 7 years ago

There are, but my thought there was that those cases were likely to be rare, and more context-specific – getData and render ought instead to be idempotent. This is specifically to avoid issues like https://github.com/ReactTraining/react-router/issues/3220.

Note that Found already does dispatch Redux actions, so if there's something you need to handle there, just listen to the actions!

brettjashford commented 6 years ago

@taion what would you recommend for an app that uses RR2 w/ react-router-relay middleware? the app does not have nested routes but must cache relay data between routes.

we've upgraded most of our app to relay modern but are stuck at the router and would prefer to make few changes at the router level if at all possible.

thanks in advance!

taion commented 6 years ago

If you're not using nested routes, then the choice of router framework doesn't make much of a difference. You wouldn't have even really needed react-router-relay.

That said, the route configuration API is in Found Relay is very similar to that of react-router-relay; compare react-router-relay to Found Relay. It's a pretty straightforward translation.

You do get one additional benefit if you use code splitting, though, in that Found Relay (unlike react-router-relay) can, when using Relay Modern, fetch data plus the split-out code component at the same time, and show loading feedback while doing so.

Relay Modern makes data caching an application-level concern, though. The most common recommendation is to use request-level caching – see discussions on e.g. the Relay repo for more details.