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

Provide way to defer checksum check during initial mount #6188

Closed
DesignByOnyx opened this issue Mar 4, 2016 · 2 comments
Closed

Provide way to defer checksum check during initial mount #6188

DesignByOnyx opened this issue Mar 4, 2016 · 2 comments

Comments

@DesignByOnyx
Copy link

We have developed a custom server side rendering solution to allow for asynchronous data loading. Once everything is done we flush the final HTML to the browser along with all of the asynchronously loaded data written to the DOM. We are also generating a checksum the same way react does with server side rendering.

During initial mount in the browser, all of the data needed by the app is available, but our data contract layer uses Promises to provide data to those who request it. Our components don't know whether or not the data is available, but our data layer does. So components use the following pseudocode for loading data:

componentWillMount () {
    SomeModel.get({ params }).then(this.setState);
}

Underneath the hood, our model layer knows whether or not the data is available and uses the data, otherwise it makes an ajax request for the data. But being that react's render is synchronous and Promises are asynchronous, there is no way for us to take advantage of the reuse-existing-markup logic within react. We have tested that if we return a synchronous Promise shim/hack, then everything works as expected - but we all know the dangers in doing this. Is there any way we can defer the checksum checks somehow? Is there a way we can render the vdom only (in memory) and then trigger the mounting logic? We don't want a detached dom with real dom nodes, we are wanting react to construct its vdom and then mount when we tell it to. Thanks.

@DesignByOnyx
Copy link
Author

Just to clarify a little, by virtue of using Promises, the app is advancing through two different states:

  1. Initial mount, data is not available synchronously (due to Promises)
  2. About 1 tick later the Promises resolve and the app enters a new state.

It would be nice if we could allow the initial mount to happen without react constructing any real DOM or mounting onto existing DOM. At some later point we would like to tell react to mount, at which point react sees the checksum and attempts to reuse the existing DOM.

@jimfb
Copy link
Contributor

jimfb commented May 3, 2016

I think this is effectively a request for #6481 and #1739. Closing as a duplicate of those two issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants