Elifaz

Untitled

Sep 13th, 2020
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        Ok vamos la! Vou te dar a resposta e ja dar algumas dicas no seu codigo.
  2.         // Parabens por estar utilizando a ultima versao do React, `hook`s are the boooomb.
  3.         import React, { useState } from 'react'
  4.        
  5.        //
  6.         export default function Valores({ value }) {
  7.  
  8.           const [recheio, setRecheio] = useState([
  9.             "Value1", "Value2", "Value3", "Value4",
  10.           ])
  11.  
  12.           const [select, setSelect] = useState([])
  13.  
  14.           const selected = (value) => {
  15.             alert(value)
  16.             setSelect([value])
  17.           }
  18.  
  19.           return (
  20.             <>
  21.               {recheio.map((value, index) => (
  22.                 <div key={index}>
  23.                   <button name={value}
  24.                     id={index} onClick={() => selected([select + value])}>
  25.                     {value}
  26.                   </button>
  27.                 </div>
  28.               ))}
  29.             </>
  30.           )
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment