-
Notifications
You must be signed in to change notification settings - Fork 45.8k
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
Should not rely on synchronous return value of renderIntoDocument #6756
Conversation
a26f4e3
to
c83ce57
Compare
@jimfb updated the pull request. |
c83ce57
to
f424a99
Compare
@jimfb updated the pull request. |
Overall I think this is an ok thing to do. For the record, I talked to Jim offline about what we think future |
// None of our tests actually require attaching the container to the | ||
// DOM, and doing so creates a mess that we rely on test isolation to | ||
// clean up, so we're going to stop honoring the name of this method | ||
// (and probably rename it eventually) if no problems arise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can safely break away from the renderIntoDocument
misnomer for something new. Might make sense to rename renderIntoDocument
(with forwarding) at the same time.
renderDetached
? Or if we want a mouthful renderIntoDetachedNode
. And then the Promise version… I guess ...Async
is ok. I still think of "async" functions as taking a callback but I guess Promises are a thing and that's how async/await works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will also eventually need a way to render into a container asynchronously.
What about ReactTestUtils.renderAsync()
which optionally accepts the second argument (container
) or renders into a detached node if no such container exists.
renderDetached
seems verbose, since 99.99% of the time, you don't care that the node is detached. You just want to render something.
Was just an idea. I truly don't have a strong preference here. Just let me know in a more definitive way when everyone is done bikeshedding and then I'll do the global replace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebmarkbage @spicyj @gaearon Do you guys want to join the bikeshedding on the function name?
Can we split this diff in twain? Use this PR to introduce and test the new API, then a 2nd to use it. Or at the very least 2 commits in this PR. |
f424a99
to
48f02ff
Compare
@jimfb updated the pull request. |
d18ef57
to
dca5799
Compare
dca5799
to
7c0d854
Compare
@jimfb updated the pull request. |
Ok, I split the usage into #6785 |
I think this is ready to go, modulo bikeshedding on the new function's name. We could also just merge this now and fix the name later... :P. |
Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired. Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status. |
Per @gaearon's comment #6785 (comment) it appears that this isn't something we'll be doing, so I'm closing this out |
Previously,
renderIntoDocument
relied on the synchronous return value of render. As per #6397, we want to start moving away from relying on this synchronous return value. This PR takes the first step toward that goal, by providing arenderIntoDocumentAsync
method, which makes it easy to render into a document and wait on the return value for the purposes of unit testing. Long term, therenderIntoDocumentAsync
is intended to replacerenderIntoDocument
for all intents and purposes.The primary motivation for this PR is that it brings our unit tests closer to matching the semantics of an incremental reconciler, thereby allowing us to iterate on our incremental reconciler without failing all the unit tests.
cc @sebmarkbage @spicyj @zpao