Skip to content

Instantly share code, notes, and snippets.

@snigo
Created October 6, 2023 09:13
Show Gist options
  • Save snigo/7a9519444a6b896842c81e5d1d5e75b3 to your computer and use it in GitHub Desktop.
Save snigo/7a9519444a6b896842c81e5d1d5e75b3 to your computer and use it in GitHub Desktop.
SOLID React article, code snippet 8: Children narrow prop in React
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