react-native
react-native copied to clipboard
Optimize runtime initialization for native components with memoization
Summary:
This pull request introduces a memoization optimization in the getNativeComponentAttributes
function to avoid redundant runtime initialization for native components. It introduces a memoization cache (configCache
) to store previously computed configurations, which are then utilized if available before computing a new one.
Changelog:
[INTERNAL|GENERAL] [ADDED] - Introduced memoization optimization to getNativeComponentAttributes
function.
Test Plan:
No changes to user interface. The code has been tested locally to ensure that previously computed configurations are utilized when available, reducing redundant computations.
Fails | |
---|---|
:no_entry_sign: |
:clipboard: Verify Changelog Format - See Changelog format |
Generated by :no_entry_sign: dangerJS against 9e766f56efae53dc8a8312f45696e526b2853d8f
@dmytrorykun does this change make sense?
Good point @dmytrorykun, not really sure however I did fix my issue with patch-package locally in a project this way, see ref. below
@admirsaheta this error means that the LEGACY_RNCViewPager
native component is not exported from native. Assuming you are on the old architecture, you should have either of the two:
-
LEGACY_RNCViewPager
, a subclass ofRCTViewManager
, that hasRCT_EXPORT_MODULE()
in its implementation. - Some other
RCTViewManager
subclass that hasRCT_EXPORT_MODULE(LEGACY_RNCViewPager)
in its implementation.
I don't see how extra caching can fix this. Could that be some other change?
@admirsaheta you must pass useNext={false}
to the pager view component, latest release of pager-view is a mess…
@admirsaheta you must pass
useNext={false}
to the pager view component, latest release of pager-view is a mess…
This fixes it as well! Thank you 👍
While I did observe improvements locally using this approach, your question about the reduction of calls to UIManager.getViewManagerConfig
raises valid concerns about the effectiveness of this optimization in real-world scenarios, still would consider it good practice to avoid unnecassary re-inits each time it's called 👍
@admirsaheta
While I did observe improvements locally using this approach
Could you describe the improvements in more details?
still would consider it good practice to avoid unnecassary re-inits each time it's called
Re-inits of what exactly? Are you seeing getNativeComponentAttributes
being called for the same component multiple times?
Yes!
@admirsaheta could you please add more details, describe how you test this, and what is the improvement that you're seeing.