Skip to content

Commit

Permalink
chore: use require syntax for resolution of all native components (#…
Browse files Browse the repository at this point in the history
…1909)

## Description

Unification of way the native components are resolved in
`index.native.tsx`.

## Changes

* Every native component is now resolved by
`require(<component_spec_file>)` instead of directly querying view
registry by using `requireNativeComponent`
* Ensured that every component spec is exported as default from its
module

## Test code and steps to reproduce

CI & launched native apps -- seems to be working fine. 

TODO: Check backward compatibility of this change

## Checklist

- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Oct 4, 2023
1 parent fd00720 commit 2468905
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Image,
ImageProps,
Platform,
requireNativeComponent,
StyleProp,
StyleSheet,
UIManager,
Expand Down Expand Up @@ -137,28 +136,29 @@ const ScreensNativeModules = {
NativeScreenNavigationContainerValue =
NativeScreenNavigationContainerValue ||
(Platform.OS === 'ios'
? requireNativeComponent('RNSScreenNavigationContainer')
? require('./fabric/ScreenNavigationContainerNativeComponent').default
: this.NativeScreenContainer);
return NativeScreenNavigationContainerValue;
},

get NativeScreenStack() {
NativeScreenStack =
NativeScreenStack || requireNativeComponent('RNSScreenStack');
NativeScreenStack ||
require('./fabric/ScreenStackNativeComponent').default;
return NativeScreenStack;
},

get NativeScreenStackHeaderConfig() {
NativeScreenStackHeaderConfig =
NativeScreenStackHeaderConfig ||
requireNativeComponent('RNSScreenStackHeaderConfig');
require('./fabric/ScreenStackHeaderConfigNativeComponent').default;
return NativeScreenStackHeaderConfig;
},

get NativeScreenStackHeaderSubview() {
NativeScreenStackHeaderSubview =
NativeScreenStackHeaderSubview ||
requireNativeComponent('RNSScreenStackHeaderSubview');
require('./fabric/ScreenStackHeaderSubviewNativeComponent').default;
return NativeScreenStackHeaderSubview;
},

Expand All @@ -167,6 +167,7 @@ const ScreensNativeModules = {
NativeSearchBar || require('./fabric/SearchBarNativeComponent').default;
return NativeSearchBar;
},

get NativeSearchBarCommands() {
NativeSearchBarCommands =
NativeSearchBarCommands ||
Expand All @@ -176,7 +177,8 @@ const ScreensNativeModules = {

get NativeFullWindowOverlay() {
NativeFullWindowOverlay =
NativeFullWindowOverlay || requireNativeComponent('RNSFullWindowOverlay');
NativeFullWindowOverlay ||
require('./fabric/FullWindowOverlayNativeComponent').default;
return NativeFullWindowOverlay;
},
};
Expand Down

0 comments on commit 2468905

Please sign in to comment.