Answers for "how to append more elements after click in react"

1

how to append more elements after click in react

const App = () => {
  const [count, setCount] = useState(0);

  return <Fragment>
    <button onClick={() => setCount(count + 1)}>Click me</button>
    { [...Array(count)].map((_, i) => <AddedElement key={i} />) }
  </Fragment>
}
Posted by: Guest on March-21-2022

Code answers related to "how to append more elements after click in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language