Answers for "new Map() collection in react state"

4

how map work in react

{this.state.data.map((person) => <TableRow key = {shortid.generate()} data = {person} />)}
Posted by: Guest on July-20-2020
-1

new Map() collection in react state

function MapComponent(){
  const [myMap, setMyMap] = useState(new Map());
  const updateMap = (k,v) => {
    setMyMap(new Map(myMap.set(k,v)));
  }
  return(
    <ul>
      {[...myMap.keys()].map(k => (
        <li key={k}>myMap.get(k)</li>
      ))}
    </ul>
  );
}
Posted by: Guest on December-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language