[Edit]
+
0
-
0

React Material-UI Select component with array of objects

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// import React, { useEffect, useState } from 'react'; // import Select from '@material-ui/core/Select/Select'; // import MenuItem from '@material-ui/core/MenuItem/MenuItem'; const options = [ {label: 'React', value: 'react'}, {label: 'JavaScript', value: 'js' }, {label: 'TypeScript', value: 'ts' } ]; return ( <Select name={name} value={value}> {options?.map(option => { return ( <MenuItem key={option.value} value={option.value}> {option.label ?? option.value} </MenuItem> ); })} </Select> );