React hook for running a function only once.
npm install @mvdlei/hooks
import React from "react"; import { useOnce } from "@mvdlei/hooks"; const App = () => { const [count, setCount] = React.useState(0); useOnce(() => { console.log("Hello World!"); }); return ( <div> <h1>Count: {count}</h1> </div> ); };
useOnce(callback: () => void): void;
use-once.ts