Skip to content

Commit aa2b1fc

Browse files
artus9033meta-codesync[bot]
authored andcommitted
Refresh DeviceInfo constants on each read
Summary: Update `NativeDeviceInfo.getConstants()` to read directly from the native module instead of retaining a stale JS-side cache. Changelog: [General][Fixed] - Refresh `DeviceInfo` constants on each read Reviewed By: javache Differential Revision: D113758830 Pulled By: cipolleschi
1 parent 2da64f4 commit aa2b1fc

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

packages/react-native/ReactNativeApi.d.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d895833bed3d3c274a6647773deaa023>>
7+
* @generated SignedSource<<ec10e8f9c4d6c2a03f0cb032a4501bde>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -84,7 +84,7 @@ declare const $$index: {
8484
get VirtualizedListContextResetter(): VirtualizedListContextResetterT
8585
get VirtualizedSectionList(): AnyVirtualizedSectionList
8686
}
87-
declare const $$NativeDeviceInfo: typeof NativeDeviceInfo_default
87+
declare const $$NativeDeviceInfo: typeof NativeModule_default
8888
declare const $$ReactFabric: typeof ReactFabric_default
8989
declare const $$ScrollViewContext: typeof ScrollViewContext_default
9090
declare const absoluteFill: AbsoluteFillStyle
@@ -281,9 +281,7 @@ declare const multiplyImpl: (
281281
b: AnimatedNode_default | number,
282282
) => AnimatedMultiplication_default
283283
declare const NativeAppEventEmitter: typeof RCTNativeAppEventEmitter_default
284-
declare const NativeDeviceInfo_default: {
285-
getConstants(): DeviceInfoConstants
286-
}
284+
declare const NativeModule_default: Spec
287285
declare const NativeModules: typeof NativeModules_default
288286
declare let NativeModules_default: {
289287
[moduleName: string]: any
@@ -4503,6 +4501,9 @@ declare type ShareOptions = {
45034501
tintColor?: ColorValue
45044502
}
45054503
declare interface Spec extends TurboModule {
4504+
readonly getConstants: () => DeviceInfoConstants
4505+
}
4506+
declare interface Spec_2 extends TurboModule {
45064507
readonly blur?: (reactTag: number) => void
45074508
readonly focus?: (reactTag: number) => void
45084509
readonly getConstantsForViewManager?: (
@@ -5350,7 +5351,7 @@ declare type TVViewPropsIOS = {
53505351
readonly tvParallaxTiltAngle?: number
53515352
}
53525353
declare type UIManager = typeof UIManager
5353-
declare interface UIManagerJSInterface extends Spec {
5354+
declare interface UIManagerJSInterface extends Spec_2 {
53545355
readonly getViewManagerConfig: (viewManagerName: string) => Object
53555356
readonly hasViewManagerConfig: (viewManagerName: string) => boolean
53565357
}
@@ -5741,7 +5742,7 @@ export {
57415742
DevMenu, // 21b8b7a9
57425743
DevSettings, // e55b91dc
57435744
DeviceEventEmitter, // bdbdd014
5744-
DeviceInfo, // 521bfb71
5745+
DeviceInfo, // 0f5a517b
57455746
DeviceInfoConstants, // 279e7858
57465747
DimensionValue, // b163a381
57475748
Dimensions, // 980ef68c

packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,5 @@ export interface Spec extends TurboModule {
4545
}
4646

4747
const NativeModule: Spec = TurboModuleRegistry.getEnforcing<Spec>('DeviceInfo');
48-
let constants: ?DeviceInfoConstants = null;
49-
50-
const NativeDeviceInfo = {
51-
getConstants(): DeviceInfoConstants {
52-
if (constants == null) {
53-
constants = NativeModule.getConstants();
54-
}
55-
return constants;
56-
},
57-
};
5848

59-
export default NativeDeviceInfo;
49+
export default NativeModule;

0 commit comments

Comments
 (0)