-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[RNMobile] Fix React Native error from function declaration hoisting #29013
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
[RNMobile] Fix React Native error from function declaration hoisting #29013
Conversation
It is unknown why relying upon function declaration hoisting causes an error in React Native, but it does occur. Recent changes with WordPress#28676 refactored a class to a functional component, including leveraging function declaration hoisting. I.e. the function was referenced prior to its declaration in terms of the order of the lines of code. Re-ordering the code so that the function declaration occurs prior to referencing it appears to resolve the error in React Native. Related: https://git.io/JtXMm
Wow! So glad you had this idea. Thanks for looking into it! I don't think it would have ever occurred to me. |
@ItsJonQ will you please review and verify the web editor focal point picker continues to function as expected, given that was the focus of #28676? @jd-alexander I believe these changes resolve the native mobile editor crash that was introduced in #28676. Will you please review and help verify? Also, I do not have write permissions for |
Thanks, @dcalhoun I have added myself and @ItsJonQ as reviewers and I will re-run test(s) in the event any of them fail. |
I've tested this for web. The focal point picker is working as expected. I can't vouch for mobile as I've not yet been able to get the RN/mobile dev env working. Also, I restarted the tests, probably a second before Joel would've seen it. |
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.
Thanks for these changes @dcalhoun 😄 I first verified that the function declaration hoisting issue existed on master and then I added your fork's remote, checked out this branch, and verified that the issue has been resolved by utilizing the blocks below since they utilize the withNotices
HOC that was refactored in the linked PR.
Blocks tested :
- Cover's edit focal point functionality
- Gallery
- Media-Text
- Audio block
Thanks again for this fix. LGTM 🚢
This issue is very strange. Function hoisting is a language feature 🤷 The fix is good but it shouldn’t be necessary. I would expect many places relaying on hoisting in the repository. |
Thanks for the fix David and thank you all for being quick at reviewing!
|
Gutenberg Mobile: wordpress-mobile/gutenberg-mobile#3150
Description
Fixes wordpress-mobile/gutenberg-mobile#3149.
It is unknown why relying upon function declaration hoisting causes an
error in React Native, but it does occur. Recent changes with #28676
refactored a class to a functional component, including leveraging
function declaration hoisting. I.e. the function was referenced
prior to its declaration in terms of the order of the lines of code.
Re-ordering the code so that the function declaration occurs prior to
referencing it appears to resolve the error in React Native.
Related: https://git.io/JtXMm
Mobile Error
How has this been tested?
Manually tested modifying the focal point for a Cover block in both the web editor (macOS Safari) and native editor (iOS).
Screenshots
Web
web-focal-point-picker.mov
Native Mobile
native-focal-point-picker.mov
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: