-
Notifications
You must be signed in to change notification settings - Fork 112
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
Existence checking examples are not equivalent #35
Comments
You're right; they aren't equivalent. The spirit behind it is that a component should always render, regardless of data. The owner alone should be making decisions about whether or not that component is renderable. It's unnecessarily confusing to have a component decides—autonomously—wether or not to render. |
I agree with this and follow this practice. I think the example you should show is my guard example, rather than |
Does this change make the scetion clearer? 996008f |
Thanks for catching those errors. They've been fixed. |
Got that last one. Thanks @evandavis for help making this section better :) |
👍 I've been a fan of this guide for a while; really happy to see it evolving. |
Thanks! This kinda stuff is always fun. It's great for having conversations like this—really fleshing out what's good and why. I appreciate your involvement. I have a couple other resources that put a little more regular attention on. http://reactcheatsheet.com I'm working on one for style next :) |
Under Existence Checking, you provide the following example:
However, these results are not equivalent. One renders nothing, the other renders a default value. I would like to see best practices for both cases.
On a related note, is there a best practice for bailing out of render vs guarding in the calling component?
Ie return null from the child
vs guarding in the parent
The text was updated successfully, but these errors were encountered: