-
Notifications
You must be signed in to change notification settings - Fork 48.6k
How to record Perf mesures on every single render? #3611
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
Comments
cc @spicyj @sebmarkbage. |
any idea @sebmarkbage ? |
nobody has any idea on this? |
BTW, Is it possible to call asynchronously a callback passed to React.render? |
@koba04 why is it a bad thing? you can still use setTimeout if you need to. |
I just wonder the reason why
Is it possible to reproduce this? |
@koba04 actually it seems you are right. In my complex app the callback seems to be called synchronously. It's not very clear but I guess React does not guarantee synchronicity in the future as they may change this behavior later? Like if they decide to use something like |
Updates happen asynchronously when calling React.render with a new React element on the same container. We might start batching initial renders too. |
nice to know. |
The result of React.createElement or any JSX expression. |
@spicyj I wasn't asking for the definition of ReactElement but rather what does it mean to have a new element for a container?
Do you mean that for the 3st render the callback will be called asynchronously? |
For the second and third renders there, I believe it's async. |
thanks |
ReactPerf doesn't work in 16 and we'll need to reevaluate the approach before introducing something like it again. I think we can close this since it's specific to the old ReactPerf. |
@gaearon So how can i get Perf results in latest version of react? |
I have an app with a framework very similar to Om where I always render from the top component.
There is no Flux store with components listening to a single Flux store event, just a single global json state managed outside of React.
I ask this question as a follow-up to this issue, as I just noticed that React.render takes a callback: #1931
My former Perf code looked like this:
So as Render takes a callback it seems to make sens to use it instead of considering React.render synchronous.
The question that directly comes to mind is what would be the behavior if the 2nd rendering is triggered before the 1st rendering callback has been called?
In an ideal world we would have
start / stop / printWasted / start / stop / printWasted
but it seem to me that we could also havestart / start / stop / printWasted / stop / printWasted
which could lead to bad or duplicated mesures, or even worse a failure if Perf does not allow to be started twice for example...I think my usecase is pretty common for those using React in a really pure way, and it would be nice to explain and document how this can be achieved without expecting weird side effects
The text was updated successfully, but these errors were encountered: