UNPKG

@wikimedia/codex

Version:

Codex Design System for Wikimedia

11 lines (10 loc) 479 B
/** * Throw a warning when a condition becomes true, but only once. * * This watches the condition function, and throws a warning when it returns true for the first * time. After that, it stops watching the condition, so that the warning is only thrown once. * * @param shouldWarn Condition to watch. When this returns true, the warning is thrown. * @param message Warning message */ export default function useWarnOnce(shouldWarn: () => boolean, message: string): void;