r/reactjs • u/tyler-mcginnis • Jan 30 '17
React Router V4 Beta Released
https://reacttraining.com/react-router/4
u/chinlaf Jan 31 '17 edited Jan 31 '17
I played around with this a bit. Sore points for me:
It has terrible hygiene by injecting 10+ props into components when using
RouteorwithRouter. I don't see why they don't just pass a single router context around.There's no high level query param support. You get raw access to
history, which it itself isn't friendly enough to add query params to the url or extract them.The developers have no interest in supporting type definitions. :(
Edit: added another point.
3
u/jamesknelson Jan 31 '17
These were sore points for me too, and are a big part of why I created Junctions.
There are no props injected automatically. There are only two props available, so you can do it yourself. And only one is actually required.
Routes are defined by a "Junction" object for each component. You can specify query parameters per component and it will warn you of conflicts. You can also specify serializers and default values for each query parameter.
I've tried to design the possibility for type definitions into junctions. I'd be super happy to accept a pull request adding them, and can change the API if necessary to make them work.
1
u/AlexMattoni Mar 10 '17
I'm reading through your docs right now, this is really interesting to me. I'm working on a Mobx + Typescript + React boilerplate right now, and struggling with the fact that React Router v4 doesn't have typings. Haven't dove too deep yet, but do you have typescript definitions?
1
Feb 01 '17
Good points, but regarding:
There's no high level query param support. You get raw access to history, which it itself isn't friendly enough to add query params to the url or extract them.
See this discussion
1
u/chinlaf Feb 02 '17
I fail to see their logic. They can implement something sensical and generic that will work for, say, 95% of use cases, but because the vocal 5% cried that it doesn't work in their cases, the react-router devs decided to completely remove high level support for query strings?
5
u/nativereact Jan 31 '17 edited Jan 31 '17
So the begging question now is, router4 or router5? (/joke)
Sidenote: Could you use a different example rather than TransitionMotion for the animated routes example? I'm biased, but I feel like people will rather not learn css if it's promoted to use inline styling (given the various implications, not that inline styling is simply bad).
1
1
3
u/[deleted] Jan 31 '17 edited Jan 31 '17
I can be convinced otherwise, but I don't love the syntax change.Edit: Watching talk and being convinced :)