In my memory, you could write this:
const SomeComponent:FC<{label: string}> = ({label, children}) => (
and I even found some documentation claiming you can do it. When I try (with React version 18.2), I just get an error saying children is not a prop.
When I do this
const SomeComponent:FC<PropsWithChildren<{label: string}>> = ({label, children}) => (
it works fine, but that’s wordy. Did this used to work and they changed it and nobody told me? Why did they change it? And why did nobody tell me?
they changed it! Implicit children prop removed from React.FunctionComponent types. in React version 18. you can check it here. Now it needs to be listed explicitly when defining props as mentioned in reactjs documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With