Skip to content

Instantly share code, notes, and snippets.

@vinnymac
Created February 1, 2023 03:19
Show Gist options
  • Select an option

  • Save vinnymac/98f62066dc0f237a8db61926c42359d5 to your computer and use it in GitHub Desktop.

Select an option

Save vinnymac/98f62066dc0f237a8db61926c42359d5 to your computer and use it in GitHub Desktop.
React 18 Children Prop Type
// React 17 or lower
type DropdownProps = {
open: boolean;
}
// React 18 or higher
type DropdownProps = {
open: boolean;
children?: React.ReactNode;
}
// Alternatively, you may use the type helper React provides
type DropdownProps = React.PropsWithChildren<{
open: boolean;
}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment