useDidUpdate

About

componentDidUpdate hook for react

Examples

import React, { useState } from "react";
import { useDidUpdate } from "rooks";

export default function App() {
  const [value, setValue] = useState(0);
  useDidUpdate(() => {
    console.log("This message was logged on update.");
  });
  return (
    <div>
      <p> Update this value by clicking on the button</p>
      <p> Current value is {value}</p>
      <p> Open the sandbox in codesandbox to view the console </p>
      <button onClick={() => setValue(value + 1)}>Increment</button>
    </div>
  );
}

Join the community!

Join our discord server! You can click the floating discord icon at the bottom right of the screen and chat with us!

Powered by vercel