Skip to content

Commit ec34501

Browse files
authored
Avoid calling AppRegistry.registerComponent in mocked mode (#7234)
1 parent dfdb451 commit ec34501

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ComponentProvider } from 'react-native';
2+
3+
export class AppRegistryService {
4+
registerComponent(_appKey: string, _getComponentFunc: ComponentProvider) {}
5+
}

lib/src/Navigation.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export class NavigationRoot {
4848

4949
constructor(
5050
private readonly nativeCommandsSender: NativeCommandsSender,
51-
private readonly nativeEventsReceiver: NativeEventsReceiver
51+
private readonly nativeEventsReceiver: NativeEventsReceiver,
52+
private readonly appRegistryService: AppRegistryService
5253
) {
5354
this.componentWrapper = new ComponentWrapper();
5455
this.store = new Store();
@@ -59,12 +60,12 @@ export class NavigationRoot {
5960
this.nativeEventsReceiver,
6061
this.store
6162
);
62-
const appRegistryService = new AppRegistryService();
63+
6364
this.componentRegistry = new ComponentRegistry(
6465
this.store,
6566
this.componentEventsObserver,
6667
this.componentWrapper,
67-
appRegistryService
68+
this.appRegistryService
6869
);
6970
this.layoutTreeParser = new LayoutTreeParser(this.uniqueIdProvider);
7071
const optionsProcessor = new OptionsProcessor(

lib/src/NavigationDelegate.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ import { OptionsProcessor as OptionProcessor } from './interfaces/Processors';
99
import { NavigationRoot } from './Navigation';
1010
import { NativeCommandsSender } from './adapters/NativeCommandsSender';
1111
import { NativeEventsReceiver } from './adapters/NativeEventsReceiver';
12+
import { AppRegistryService } from './adapters/AppRegistryService';
1213

1314
export class NavigationDelegate {
1415
private concreteNavigation: NavigationRoot;
1516
constructor() {
1617
this.concreteNavigation = this.createConcreteNavigation(
1718
new NativeCommandsSender(),
18-
new NativeEventsReceiver()
19+
new NativeEventsReceiver(),
20+
new AppRegistryService()
1921
);
2022
}
2123

2224
private createConcreteNavigation(
2325
nativeCommandsSender: NativeCommandsSender,
24-
nativeEventsReceiver: NativeEventsReceiver
26+
nativeEventsReceiver: NativeEventsReceiver,
27+
appRegistryService: AppRegistryService
2528
) {
26-
return new NavigationRoot(nativeCommandsSender, nativeEventsReceiver);
29+
return new NavigationRoot(nativeCommandsSender, nativeEventsReceiver, appRegistryService);
2730
}
2831

2932
/**
@@ -226,9 +229,11 @@ export class NavigationDelegate {
226229
public mockNativeComponents() {
227230
const { NativeCommandsSender } = require('./Mock/mocks/NativeCommandsSender');
228231
const { NativeEventsReceiver } = require('./Mock/mocks/NativeEventsReceiver');
232+
const { AppRegistryService } = require('./Mock/mocks/AppRegistryService');
229233
this.concreteNavigation = this.createConcreteNavigation(
230234
new NativeCommandsSender(),
231-
new NativeEventsReceiver()
235+
new NativeEventsReceiver(),
236+
new AppRegistryService()
232237
);
233238
}
234239

0 commit comments

Comments
 (0)