Open
Description
openedon Oct 31, 2024
The type of the children prop in FlagsmithContextType
doesn't align with the type normally used for children props which results in having to wrap an actual children prop used inside a FlagsmithProvider with a fragment to make it work without TS errors. Perhaps the type could be changed from ReactElement | ReactElement[]
to simply ReactNode
, which would be the same as the PropsWithChildren
generic type provided by React.
// Example of error
type FeatureFlagProviderType = {
serverState: IState;
};
export const FeatureFlagProvider = ({
serverState,
children, // ReactNode
}: PropsWithChildren<FeatureFlagProviderType>) => {
const flagsmithInstance = useRef(createFlagsmithInstance());
return (
<FlagsmithProvider
flagsmith={flagsmithInstance.current}
serverState={serverState}
>
{children}
</FlagsmithProvider>
);
};
However, by wrapping children with a fragment or something else, there are no issues.
Perhaps I'm missing something, but is there any special reasoning behind using ReactElement | ReactElement[]
for children?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels