Skip to content

Commit 12edf29

Browse files
authored
chore(types): remove nullability from some children props in unstable/experimental components (#3918)
## Description This PR is a follow-up to #3719. We adjust `children` property to be not nullable for `Host` components (Tabs, Split and Stack v5) and subviews in Stack v5 implementation. This change is applied only to unstable/experimental components so it shouldn't be considered a breaking change. ## Changes - wrap `ReactNode`/`ViewProps['children']` in `NonNullable` for: - `StackHost` - `TabsHost` - `SplitHost` - `StackHeaderSubview` and related places in `StackHeaderConfig` ## Before & after - visual documentation N/A ## Test plan `yarn check-types` ## Checklist - [x] For API changes, updated relevant public types. - [x] Ensured that CI passes
1 parent 7ac4bb6 commit 12edf29

6 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/components/gamma/split/SplitHost.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export type SplitHostCommands = {
113113
};
114114

115115
export interface SplitHostProps extends ViewProps {
116-
children?: React.ReactNode | undefined;
116+
children: NonNullable<React.ReactNode>;
117117
ref?: React.Ref<SplitHostCommands> | undefined;
118118

119119
/**

src/components/gamma/stack/header/StackHeaderConfig.android.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface StackHeaderToolbarSubviewAndroid {
2626
*
2727
* @platform android
2828
*/
29-
Component: ReactNode;
29+
Component: NonNullable<ReactNode>;
3030
}
3131

3232
export interface StackHeaderBackgroundSubviewAndroid {
@@ -58,7 +58,7 @@ export interface StackHeaderBackgroundSubviewAndroid {
5858
*
5959
* @platform android
6060
*/
61-
Component: ReactNode;
61+
Component: NonNullable<ReactNode>;
6262
}
6363

6464
export interface StackHeaderConfigPropsAndroid {

src/components/gamma/stack/header/android/StackHeaderSubview.android.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type StackHeaderSubviewTypeAndroid =
99
export type StackHeaderSubviewCollapseModeAndroid = 'off' | 'parallax';
1010

1111
export type StackHeaderSubviewProps = {
12-
children?: ViewProps['children'] | undefined;
12+
children: NonNullable<ViewProps['children']>;
1313

1414
type?: StackHeaderSubviewTypeAndroid | undefined;
1515
collapseMode?: StackHeaderSubviewCollapseModeAndroid | undefined;

src/components/gamma/stack/host/StackHost.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ReactNativeElement, ViewProps } from 'react-native';
33
import { type NativeProps } from '../../../../fabric/gamma/stack/StackHostNativeComponent';
44

55
export type StackHostProps = {
6-
children: ViewProps['children'];
6+
children: NonNullable<ViewProps['children']>;
77
// TODO: Work on these types
88
ref?:
99
| React.RefObject<

src/components/tabs/host/TabsHost.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export interface TabsHostPropsBase {
167167
rejectStaleNavStateUpdates?: boolean | undefined;
168168

169169
// General
170-
children?: ViewProps['children'] | undefined;
170+
children: NonNullable<ViewProps['children']>;
171171
/**
172172
* @summary Hides the tab bar.
173173
*

src/flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const compatibilityFlags = {
6565
* * https://github.com/software-mansion/react-native-screens/pull/3863
6666
* * https://github.com/software-mansion/react-native-screens/pull/3875
6767
* * https://github.com/software-mansion/react-native-screens/pull/3895
68+
* * https://github.com/software-mansion/react-native-screens/pull/3918
6869
*/
6970
usesStableTabsApi: true,
7071
} as const;

0 commit comments

Comments
 (0)