UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

17 lines (16 loc) 447 B
import { useRef } from 'react'; /** * * Hook to run code once in a functional component. * Emulates the behaviour of a `constructor` in a class component * Place this at the top of your functional component so that it is run first. * * @param callback Callback function to run once */ export default function useConstructor(callback) { var hasRun = useRef(false); if (!hasRun.current) { callback(); hasRun.current = true; } }