React cheatsheet
Published 3 months ago: October 27, 2020
React cheatsheet
In this post
This cheatsheet is a small collection of handy snippets for quick reference in tricky situations. Feel free to suggest edits, propose additions, complain about something, disagree with content or such and the like. Every feedback is a welcome one.
Run function on component render
import React, { useEffect } from "react"
useEffect(() => {
console.log('This runs on every render')
})
// add and empty array as a callback to run once, instead of on every render
useEffect(() => {
console.log('This runs exactly once')
}, [])