Skip to content

Commit c19f9b0

Browse files
update type definitions to not restrict the type of children props
1 parent 476dbc4 commit c19f9b0

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1.9.1 (September XX, 2023)
1+
1.9.1 (October XX, 2023)
2+
- Updated type definitions of the library components to not restrict the type of the `children` prop to ReactElement, allowing to pass any valid ReactNode value (Related to issue https://github.com/splitio/react-client/issues/164).
23
- Updated linter and other dependencies for vulnerability fixes.
34

45
1.9.0 (July 18, 2023)

src/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SplitIO from '@splitsoftware/splitio/types/splitio';
2+
import type { ReactNode } from 'react';
23

34
/**
45
* Split Status interface. It represents the current readiness state of the SDK.
@@ -124,7 +125,7 @@ export interface ISplitFactoryProps extends IUpdateProps {
124125
/**
125126
* Children of the SplitFactory component. It can be a functional component (child as a function) or a React element.
126127
*/
127-
children: ((props: ISplitFactoryChildProps) => JSX.Element | null) | JSX.Element | null;
128+
children: ((props: ISplitFactoryChildProps) => ReactNode) | ReactNode;
128129
}
129130

130131
/**
@@ -159,7 +160,7 @@ export interface ISplitClientProps extends IUpdateProps {
159160
/**
160161
* Children of the SplitFactory component. It can be a functional component (child as a function) or a React element.
161162
*/
162-
children: ((props: ISplitClientChildProps) => JSX.Element | null) | JSX.Element | null;
163+
children: ((props: ISplitClientChildProps) => ReactNode) | ReactNode;
163164
}
164165

165166
/**
@@ -197,5 +198,5 @@ export interface ISplitTreatmentsProps {
197198
/**
198199
* Children of the SplitTreatments component. It must be a functional component (child as a function) you want to show.
199200
*/
200-
children: ((props: ISplitTreatmentsChildProps) => JSX.Element | null);
201+
children: ((props: ISplitTreatmentsChildProps) => ReactNode);
201202
}

types/types.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// <reference types="react" />
21
import SplitIO from '@splitsoftware/splitio/types/splitio';
2+
import type { ReactNode } from 'react';
33
/**
44
* Split Status interface. It represents the current readiness state of the SDK.
55
*/
@@ -103,7 +103,7 @@ export interface ISplitFactoryProps extends IUpdateProps {
103103
/**
104104
* Children of the SplitFactory component. It can be a functional component (child as a function) or a React element.
105105
*/
106-
children: ((props: ISplitFactoryChildProps) => JSX.Element | null) | JSX.Element | null;
106+
children: ((props: ISplitFactoryChildProps) => ReactNode) | ReactNode;
107107
}
108108
/**
109109
* SplitClient Child Props interface. These are the props that the child component receives from the 'SplitClient' component.
@@ -131,7 +131,7 @@ export interface ISplitClientProps extends IUpdateProps {
131131
/**
132132
* Children of the SplitFactory component. It can be a functional component (child as a function) or a React element.
133133
*/
134-
children: ((props: ISplitClientChildProps) => JSX.Element | null) | JSX.Element | null;
134+
children: ((props: ISplitClientChildProps) => ReactNode) | ReactNode;
135135
}
136136
/**
137137
* SplitTreatments Child Props interface. These are the props that the child component receives from the 'SplitTreatments' component.
@@ -163,6 +163,6 @@ export interface ISplitTreatmentsProps {
163163
/**
164164
* Children of the SplitTreatments component. It must be a functional component (child as a function) you want to show.
165165
*/
166-
children: ((props: ISplitTreatmentsChildProps) => JSX.Element | null);
166+
children: ((props: ISplitTreatmentsChildProps) => ReactNode);
167167
}
168168
export {};

0 commit comments

Comments
 (0)