-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[V4] <Match> / <Miss> children #4033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Additional use case: <Match pattern="/config">
<ConfigFrame>
<Match pattern="/config/foo" component={FooConfig} />
<Match pattern="/config/bar" component={BarConfig} />
<Match pattern="/config/baz/:id" component={BazConfig} />
</ConfigFrame>
</Match> |
Match supports children. It's at the bottom of the page you linked. The reason we take a function is so the React Element doesn't have to be instantiated unless the Match matches. In your example, the child components are always instantiated, even if the pattern doesn't match. |
@jampy some more notes on why: https://gist.github.com/ryanflorence/a301dc184f75e929a263dc1e80399a28 |
Thanks @timdorr and @ryanflorence for the hint. Makes a lot of sense performance-wise! :-)
But |
You should have gotten a propType warning: https://github.com/ReactTraining/react-router/blob/v4/modules/Match.js#L111 |
indeed so, no components as childs |
According to the docs,
<Match>
and<Miss>
can only be configured using props and don't seem to expect any children.Is there a good reason not to support (also) something like this?
I understand that this way the component does not receive props from Match/Miss, but for static routes (no
:param
) and for static content (for example, theThis is Bar!
text) this makes it much more readable, IMHO.The text was updated successfully, but these errors were encountered: