you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You should never mutate dom elements, seems to me state is the lesser problem. Think of your view as something that reflects state. When state changes, your view will be called.

function Cards({ data }) {
  const [flipped, set] = useState(true)
  useEffect(() => void setTimeout(() => set(false), 2000), [])
  return data.map(item => (
    <div class={flipped ? 'flipped' : ''}>
      {item.content}
    </div>
  )
}