Created
October 6, 2023 09:13
-
-
Save snigo/7a9519444a6b896842c81e5d1d5e75b3 to your computer and use it in GitHub Desktop.
SOLID React article, code snippet 8: Children narrow prop in React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ANarrowProps { | |
children: string; | |
} | |
interface BNarrowProps { | |
childNodes: string; | |
} | |
export const ANarrow = ({ children }: ANarrowProps) => { | |
return <section>{children}</section>; | |
}; | |
export const BNarrow = ({ childNodes }: BNarrowProps) => { | |
return <section>{childNodes}</section>; | |
}; | |
export const Sections = () => { | |
return ( | |
<> | |
<ANarrow>Children as a nested text node</ANarrow> | |
<ANarrow children="Children as prop instead" /> | |
<BNarrow childNodes="Let's rename the prop" /> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment