-
Notifications
You must be signed in to change notification settings - Fork 1.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
onLayout Callback called before ref Callback #911
Comments
Please can you include a link to a test case that reproduces the issue |
Not sure how it could be possible since React is meant to update the DOM and refs before |
Here is a minimal test case: Code: It works on Chrome, it does not work on Firefox 59 |
Thanks. The layout handler is here and is only being called in |
@giuseppeg I'm thinking the resize observer patch might be involved in this issue |
@necolas I can take a look later today. fwiw onLayout={() => { setTimeout(() => { console.log(typeof this.myref) }) } works on FF. |
@necolas I think we got tricked by the fact that ResizeObserver is async. The fallback behavior is actually the correct one since the OP is attaching a ref on an instance and trying to access it in the render method right away. The correct order is:
https://codepen.io/giuseppegurgone/pen/vjKzyv We should fix the ResizeObserver case to fire immediately like we do in the fallback case
|
onLayout is called synchronously when `ResizeObserver` is being used. Fix #911
onLayout is called synchronously when `ResizeObserver` is being used. Fix #911
Do you want to request a feature or report a bug?
It might be considered a bug
What is the current behavior?
The OnLayout Callback is called before the ref callback on component mount.
If the current behavior is a bug, please provide the steps to reproduce and
What is the expected behavior?
On RN native (IOS & Android )
Sequence is
1 ref callback
2 onlayout
It used to be like this on RNWEB
Environment (include versions). Did this work in previous versions?
Confirmed the change affects
it does not seem to affect chrome
Could it be related to a67bf0f
If the change is intented and we need to handle this manually could you please let us know.
Thank you for the amazing work.
The text was updated successfully, but these errors were encountered: