-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Provide a prop on <Suspense>
to let children mount/unmount instead of changing style
#18856
Comments
Could you explain your specific usecase/issue that makes you desire this behaviour? |
@threepointone I came across this behavior when I was doing snapshot for suspense rendering results with jest. I need to filter out the hidden children and find the actual rendered fallback element to detect if it's suspended. but I'm wondering there would be some cases that people don't want the nodes just be hidden, remounting can also be a choice. other effects like the order of elements will change, that fallback might not be the only element or can become the second element. |
iirc, the dom elements might be holding state, so it's actually important that they stay in the dom. It's also a little odd to do visibility checks with snapshots. Consider that some other code, even user code, might have hidden a parent element. Then your test would pass even though it doesn't 'work' as expected. As an immediate workaround, I'd recommend making a helper, something like |
Sounds like a duplicate of #14536 This is a known quirk with
|
^ He's right, but that would require you to migrate to concurrent mode, which isn't really a recommended option at the moment. |
Yeah. To make this more clear: If this is a duplicate of #14536 then this can't be fixed in stable react 16 as per comment from Dan in #14536 (comment). |
Thanks for clarification @eps1lon 👍. @threepointone work around on testing side make sense, thanks for the help. |
Feature Request
Currently react render children of Suspense with inline style
display: none !important
, referenced PR. would like to have a prop likemount
or sth else to remount the children when suspended state changed.Example
the above code will only render fallback component
instead of
The text was updated successfully, but these errors were encountered: