-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
(iOS) - NativeCommands fail in ref functions if batchRenderingUpdatesInEventLoop is active #46330
Comments
|
|
Upgraded reproducer to |
@cortinico can I work on this? |
@elencho feel free to investigate further. Context from @rubennorte:
|
Our library is dependent on the immediate firing of As we wait for this change, what would you @cortinico suggest as a workaround for now on this race condition? Is using |
I'm not familiar with your use case, so it's hard to suggest a workaround. Maybe you can queue those commands in native instead? |
At Fullstory we use method swizzling to get React classes to call our All of this is to allow us to read a custom prop in the native code like: In new architecture, everything is strongly typed in C++, so this is our workaround to read We need to read these props on view creation, and since it's React Classes that we're calling |
@RyanCommits oh, I see. Would it make sense to use custom components instead of the RN built-ins in that case? Maybe replace |
The idea is for our users to be able to plug and play - install our plugin with minimal code changes and be able to tag their components. We could build a custom component, but then our users will have to replace every component that requires this feature. We would also lose the ability to use our babel plugin to auto-tag components with identifying props, including components within other libraries. |
Description
Problem
Starting in version
0.74.1
and above, due to this change, thebatchRenderingUpdatesInEventLoop
feature flag is turned ON. This causes NativeCommands called inref
functions to fail.The corresponding NativeCommand:
Diagnosis
The NativeCommand
trigger
fails because when synchronouslyDispatchCommandOnUIThread gets called,findComponentViewWithTag
returnsnil
because the _registry does not contain the element.When
batchRenderingUpdatesInEventLoop
is off, the_registry
is correctly populated with all elements on the screen, and the NativeCommandtrigger
functions correctly.If
Commands.trigger
is wrapped in asetTimeout
, it gets called successfully.Steps to reproduce
See the reproducer provided.
codegenNativeComponent
andcodegenNativeCommands
to create aNativeCommand
NativeCommand
in aref
functionNativeCommand
does NOT get called in versions>=0.74.1
React Native Version
0.74.5
Affected Platforms
Runtime - iOS
Areas
JSI - Javascript Interface, Bridgeless - The New Initialization Flow
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/RyanCommits/RN74-issue-reproducer
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: