EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
hooks·hook·@astryxdesign/core

useDevWarning

Fires a dev-only "Component: message" console warning once per mount while the condition holds. It is the render-safe way for a component to flag misuse: warning straight from the render body repeats on every render, and gating it with state adds a re-render, so this uses a ref and an effect instead. For a warning outside a component, use the imperative devWarn utility.

@astryxdesign/core/hooks

Signature

Call shape
useDevWarning(component: string, message: string, condition: boolean = true): void
Parameters
NameType and behavior
componentstring · required
Component or hook name, used as the message prefix.
messagestring · required
What went wrong and how to fix it.
conditionboolean · optional · default true
Whether to warn.

Usage

Fires a dev-only "Component: message" console warning once per mount while the condition holds. It is the render-safe way for a component to flag misuse: warning straight from the render body repeats on every render, and gating it with state adds a re-render, so this uses a ref and an effect instead. For a warning outside a component, use the imperative devWarn utility.

  • Say what is wrong and what the builder should do instead; the message is the whole value of the warning.
  • Warn about combinations the types cannot express, such as two mutually exclusive props being set together.
  • Use it for anything a user could see or for runtime error handling; it is stripped from production builds.