14 lines
519 B
JavaScript
14 lines
519 B
JavaScript
'use client';
|
|
|
|
import * as React from 'react';
|
|
import { EMPTY_ARRAY } from "./empty.mjs";
|
|
|
|
/**
|
|
* A React.useEffect equivalent that runs once, when the component is mounted.
|
|
*/
|
|
export function useOnMount(fn) {
|
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- no need to put `fn` in the dependency array
|
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
React.useEffect(fn, EMPTY_ARRAY);
|
|
/* eslint-enable react-hooks/exhaustive-deps */
|
|
} |