logologo

onUpdate and onUnmount in ReactJS hooks.

onUpdate in Reactjs hooks:

import { useEffect } from "react"

function App() {
  useEffect(() => {
    // on mount
    return () => {
      // call if component update
    }
  })

  return <div>App</div>
}

onUnmount in Reactjs hooks:

import { useEffect } from "react"

function App() {
  useEffect(() => {
    // on mount
    return () => {
      // call if component unmount
    }
  }, [])

  return <div>App</div>
}
MIT 2023 © Tachibana Shin (橘芯)