Skip to content

Instantly share code, notes, and snippets.

@Enough7
Last active August 12, 2021 09:33
Show Gist options
  • Save Enough7/96f3b69e02958d8c96f9fa54102648f0 to your computer and use it in GitHub Desktop.
Save Enough7/96f3b69e02958d8c96f9fa54102648f0 to your computer and use it in GitHub Desktop.
Output Array of Elements in a React Hook (Typescript)
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