5.1.0
https://codesandbox.io/s/reverent-water-wvdvp
Change the version of react-router-dom between 5.1.0 and 5.0.1
Both versions of react-router-dom render the same thing
[email protected] treats <Route children> differently than previous versions. Previously, children were ALWAYS shown, regardless of being matched or not. Now they only show if the path matches. This should be considered a breaking change.
Also wanna express my extreme excitement for 5.1.0 and don't mean to take the wind out of your sails. Congrats on shipping and thanks for your continued effort!
Not sure why this is not marked as a breaking change but it is definitely one and it was also planned as one. If you want to have the same behaviour as before you either have to omit the path prop or the path must be "*". The previous behaviour was just useless and I think in RR6 or so at least <Route render> will be dropped because they both have the same behaviour but <Route children> is the "prettier" one of the both.
To be honest: we could also drop <Route component> because we can do the same with <Route children>:
<Route path="/foo" component={Foo} />
// same as
<Route path="/foo">
<Foo />
</Route>
// or shorter
<Route path="/foo" children={<Foo />} />
Just found the discussion in #6362 where the team states they consider the old behavior a bug and not part of the public interface. In that context I guess it makes sense for this to be considered a bugfix and not a breaking change, given that with the old behavior children was probably rarely used with a ReactNode instead of a function. Arguably, it _was_ part of the observable public interface, albeit not well documented.
I will say however that this behavioral change was surprising to me given how I understood children to work. There was some cognitive dissonance reading the 5.1 announcement blog post around the now-recommended way to use Route. It might be worth making this change a bit more pronounced in the release notes / blog post.
Most helpful comment
Just found the discussion in #6362 where the team states they consider the old behavior a bug and not part of the public interface. In that context I guess it makes sense for this to be considered a bugfix and not a breaking change, given that with the old behavior
childrenwas probably rarely used with a ReactNode instead of a function. Arguably, it _was_ part of the observable public interface, albeit not well documented.I will say however that this behavioral change was surprising to me given how I understood
childrento work. There was some cognitive dissonance reading the 5.1 announcement blog post around the now-recommended way to useRoute. It might be worth making this change a bit more pronounced in the release notes / blog post.