Last active
August 12, 2021 09:33
-
-
Save Enough7/96f3b69e02958d8c96f9fa54102648f0 to your computer and use it in GitHub Desktop.
Output Array of Elements in a React Hook (Typescript)
This file contains hidden or 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
export let SomeIcons = (): JSX.Element => { | |
let allIcons: ReactNode[] = [ | |
<Flight/>, // Airplane Icon | |
<Flight/>, | |
<Flight/> | |
]; | |
return ( | |
<Grid container> | |
{props.allIcons[0]} | |
{props.allIcons.map( // Use .map() not .forEach() | |
(icon: ReactNode, index: number) => ( // check () => () or () => {return ...} not () => {} | |
<Grid item> | |
{icon} | |
<Cell cellContent={<Flight/>} isSelected={false}/> | |
</Grid> | |
) | |
)} | |
</Grid> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment