Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

jimfb
Copy link
Contributor

@jimfb jimfb commented May 12, 2016

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 a renderIntoDocumentAsync method, which makes it easy to render into a document and wait on the return value for the purposes of unit testing. Long term, the renderIntoDocumentAsync is intended to replace renderIntoDocument 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

@jimfb jimfb force-pushed the render-into-document-async branch 2 times, most recently from a26f4e3 to c83ce57 Compare May 12, 2016 05:39
@ghost
Copy link

ghost commented May 12, 2016

@jimfb updated the pull request.

@jimfb jimfb force-pushed the render-into-document-async branch from c83ce57 to f424a99 Compare May 16, 2016 20:34
@facebook-github-bot
Copy link

@jimfb updated the pull request.

@zpao
Copy link
Member

zpao commented May 16, 2016

Overall I think this is an ok thing to do. For the record, I talked to Jim offline about what we think future render API looks like. It's unclear at this point how incremental reconciliation would change things so instead of trying to plan a test utils API that mirrors that hypothetical API, we should pave forward and wrap with something useful in the mean time.

// 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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

@zpao
Copy link
Member

zpao commented May 16, 2016

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.

@jimfb jimfb force-pushed the render-into-document-async branch from f424a99 to 48f02ff Compare May 16, 2016 22:28
@ghost
Copy link

ghost commented May 16, 2016

@jimfb updated the pull request.

@jimfb jimfb force-pushed the render-into-document-async branch 3 times, most recently from d18ef57 to dca5799 Compare May 16, 2016 22:49
@jimfb jimfb force-pushed the render-into-document-async branch from dca5799 to 7c0d854 Compare May 16, 2016 22:50
@ghost
Copy link

ghost commented May 16, 2016

@jimfb updated the pull request.

@jimfb
Copy link
Contributor Author

jimfb commented May 16, 2016

Ok, I split the usage into #6785

@jimfb
Copy link
Contributor Author

jimfb commented May 16, 2016

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.

@facebook-github-bot
Copy link

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.

@aweary
Copy link
Contributor

aweary commented Jan 26, 2017

Per @gaearon's comment #6785 (comment) it appears that this isn't something we'll be doing, so I'm closing this out

@aweary aweary closed this Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants