-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Appearance: Lazily Initialize NativeAppearance
#46123
Conversation
This pull request was exported from Phabricator. Differential Revision: D61578726 |
This pull request was exported from Phabricator. Differential Revision: D61578726 |
a5a5930
to
7623a44
Compare
Summary: Pull Request resolved: facebook#46123 Optimizes initialization performance by changing `Appearance` to lazily import `NativeAppearance` and setup its listeners. Changelog: [General][Changed] - Improve `Appearance` performance overhead by lazily initializing the NativeModule Reviewed By: rickhanlonii Differential Revision: D61578726
Summary: Pull Request resolved: facebook#46123 Optimizes initialization performance by changing `Appearance` to lazily import `NativeAppearance` and setup its listeners. Changelog: [General][Changed] - Improve `Appearance` performance overhead by lazily initializing the NativeModule Reviewed By: rickhanlonii Differential Revision: D61578726
This pull request was exported from Phabricator. Differential Revision: D61578726 |
7623a44
to
bc3f398
Compare
This pull request has been merged in b86e8ef. |
This pull request was successfully merged by @yungsters in b86e8ef When will my fix make it into a release? | How to file a pick request? |
Summary: currently running jest test, it shows an error: ``` ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From __tests__/App.test.tsx. at getState (node_modules/react-native/Libraries/Utilities/Appearance.js:18:26) at addChangeListener (node_modules/react-native/Libraries/Utilities/Appearance.js:71:19) at subscribe (node_modules/react-native/Libraries/Utilities/useColorScheme.js:10:66) at subscribeToStore (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6232:10) at commitHookEffectListMount (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13038:26) at commitPassiveMountOnFiber (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14461:11) at commitPassiveMountEffects_complete (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14421:9) at commitPassiveMountEffects_begin (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14408:7) at commitPassiveMountEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:14396:3) at flushPassiveEffectsImpl (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16287:3) at flushPassiveEffects (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16236:14) at node_modules/react-test-renderer/cjs/react-test-renderer.development.js:16051:9 at workLoop (node_modules/scheduler/cjs/scheduler.development.js:266:34) at flushWork (node_modules/scheduler/cjs/scheduler.development.js:239:14) at Immediate.performWorkUntilDeadline [as _onImmediate] (node_modules/scheduler/cjs/scheduler.development.js:533:21) ``` it is a regression from #46123 that to have a lazy require. this pr tries to mock `useColorScheme` to return `light`. i think we don't necessarily test the color scheme changes in jest runtime. originally `useColorScheme` also returns `light` because of [this statement](https://github.com/facebook/react-native/blob/9a60038a40e16925ea1adeb3e3c937c22a615485/packages/react-native/Libraries/Utilities/Appearance.js#L77-L83) ## Changelog: [GENERAL] [FIXED] - Fixed jest error from Appearance.js Pull Request resolved: #47629 Test Plan: ```sh $ npx react-native-community/cli init RN0762 --pm bun --version 0.76.2 $ cd RN0762 $ bun test run ``` Reviewed By: cipolleschi Differential Revision: D66297456 Pulled By: huntie fbshipit-source-id: 80d1460532e76bd1815c66964547b50d7f7b3558
Summary:
Optimizes initialization performance by changing
Appearance
to lazily importNativeAppearance
and setup its listeners.Changelog:
[General][Changed] - Improve
Appearance
performance overhead by lazily initializing the NativeModuleDifferential Revision: D61578726