Skip to content

Commit 39e3cb1

Browse files
authored
Pass componentName to NavigationProps (#7757)
* Pass componentName to NavigationProps * Update NavigationComponentProps.ts
1 parent 1dd7eed commit 39e3cb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+117
-117
lines changed

lib/src/components/ComponentWrapper.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ describe('ComponentWrapper', () => {
117117
renderer.create(<NavigationComponent componentId={'component123'} />);
118118
expect(myComponentProps).toEqual({
119119
componentId: 'component123',
120+
componentName,
120121
numberProp: 1,
121122
stringProp: 'hello',
122123
objectProp: { a: 2 },
@@ -251,7 +252,10 @@ describe('ComponentWrapper', () => {
251252
const NavigationComponent = uut.wrap(componentName, generator, store, componentEventsObserver);
252253
const tree = renderer.create(<NavigationComponent componentId={'component123'} />);
253254
expect(tree.root.findByType(View)).toBeDefined();
254-
expect(tree.root.findByType(MyComponent).props).toEqual({ componentId: 'component123' });
255+
expect(tree.root.findByType(MyComponent).props).toEqual({
256+
componentId: 'component123',
257+
componentName,
258+
});
255259
});
256260

257261
it('sets component instance in store when constructed', () => {

lib/src/components/ComponentWrapper.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ export class ComponentWrapper {
7979

8080
render() {
8181
return (
82-
<GeneratedComponentClass {...this.state.allProps} componentId={this.state.componentId} />
82+
<GeneratedComponentClass
83+
{...this.state.allProps}
84+
componentId={this.state.componentId}
85+
componentName={componentName}
86+
/>
8387
);
8488
}
8589

lib/src/interfaces/NavigationComponent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
ComponentDidAppearEvent,
1010
ComponentDidDisappearEvent,
1111
} from './ComponentEvents';
12-
import { NavigationComponentProps } from './NavigationComponentProps';
12+
import { NavigationProps } from './NavigationComponentProps';
1313
import { Options } from './Options';
1414

1515
export class NavigationComponent<Props = {}, State = {}, Snapshot = any> extends React.Component<
16-
Props & NavigationComponentProps,
16+
Props & NavigationProps,
1717
State,
1818
Snapshot
1919
> {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @deprecated This type replaced with NavigationProps
3+
*/
14
export interface NavigationComponentProps {
25
componentId: string;
36
}
7+
8+
export interface NavigationProps {
9+
componentId: string;
10+
componentName: string;
11+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
2-
import { NavigationComponentProps } from './NavigationComponentProps';
2+
import { NavigationProps } from './NavigationComponentProps';
33
import { Options } from './Options';
44

55
export interface NavigationFunctionComponent<Props = {}>
6-
extends React.FunctionComponent<Props & NavigationComponentProps> {
7-
options?: ((props: Props & NavigationComponentProps) => Options) | Options;
6+
extends React.FunctionComponent<Props & NavigationProps> {
7+
options?: ((props: Props & NavigationProps) => Options) | Options;
88
}

playground/src/components/TopBarBackground.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { StyleSheet, View, ViewStyle } from 'react-native';
3-
import { NavigationComponentProps } from 'react-native-navigation';
3+
import { NavigationProps } from 'react-native-navigation';
44

5-
interface TopBarBackgroundProps extends NavigationComponentProps {
5+
interface TopBarBackgroundProps extends NavigationProps {
66
color: string;
77
}
88

playground/src/screens/Alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import { StyleSheet, Text, Button, View, ViewStyle, TextStyle } from 'react-native';
3-
import { Navigation, NavigationComponentProps } from 'react-native-navigation';
3+
import { Navigation, NavigationProps } from 'react-native-navigation';
44
import testIDs from '../testIDs';
55

6-
interface Props extends NavigationComponentProps {
6+
interface Props extends NavigationProps {
77
title: string;
88
message: string;
99
}

playground/src/screens/BackButtonScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NavigationComponentProps, Options } from 'react-native-navigation';
2+
import { NavigationProps, Options } from 'react-native-navigation';
33
import Root from '../components/Root';
44
import Button from '../components/Button';
55
import Screens from './Screens';
@@ -17,7 +17,7 @@ const {
1717
BACK_BUTTON,
1818
} = testIDs;
1919

20-
export default class BackButtonScreen extends React.Component<NavigationComponentProps> {
20+
export default class BackButtonScreen extends React.Component<NavigationProps> {
2121
visible: boolean = true;
2222
static options(): Options {
2323
return {

playground/src/screens/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
ViewStyle,
1010
TextStyle,
1111
} from 'react-native';
12-
import { Navigation, NavigationComponentProps } from 'react-native-navigation';
12+
import { Navigation, NavigationProps } from 'react-native-navigation';
1313

14-
interface Props extends NavigationComponentProps {
14+
interface Props extends NavigationProps {
1515
title: string;
1616
accessibilityLabel?: string;
1717
color: string;

playground/src/screens/ContextScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { Text, Button, StyleSheet, ViewStyle, TextStyle } from 'react-native';
3-
import { NavigationComponentProps } from 'react-native-navigation';
3+
import { NavigationProps } from 'react-native-navigation';
44
import Root from '../components/Root';
55
import { GlobalContext, Context } from '../context';
66

7-
export default class ContextScreen extends React.Component<NavigationComponentProps> {
7+
export default class ContextScreen extends React.Component<NavigationProps> {
88
static contextType = Context;
99

1010
static options() {

0 commit comments

Comments
 (0)