Skip to content

Hooks

@isudev/gutenberg/hooks is a collection of small, focused React hooks for building Gutenberg blocks: responsive attribute editing, post-editor context, and a couple of general value-handling utilities. Every hook lives in its own folder with its own README — this page is just a map to them.

import { usePrevious } from '@isudev/gutenberg/hooks';
import { usePrevious } from '@isudev/gutenberg/hooks/usePrevious';
Hook What it does
useBreakpoint Owns the selected breakpoint, with optional two-way sync to the editor’s device preview.
useResponsiveAttribute Reads and writes one logical setting across a breakpoint set.
useCurrentPostType Returns the post type of the post currently open in the editor.
useCurrentPostId Returns the ID of the post currently open in the editor.
useDebouncedValue Returns a debounced copy of a value that only updates after a delay of no changes.
usePrevious Returns the value a component held on its previous committed render.

If you want the whole responsive control — switcher, selection state and attribute plumbing wired together — see ResponsiveControl instead of composing the pieces yourself.

Module What it does Narrowest import
useBreakpoint Owns which breakpoint a responsive setting is currently being edited for, with optional two-way sync to the editor’s device preview. @isudev/gutenberg/hooks/useBreakpoint
useCurrentPostId Returns the ID of the post currently open in the editor. @isudev/gutenberg/hooks/useCurrentPostId
useCurrentPostType Returns the post type of the post currently open in the editor. @isudev/gutenberg/hooks/useCurrentPostType
useDebouncedValue Returns a debounced copy of a value that only updates after a delay of no further changes. @isudev/gutenberg/hooks/useDebouncedValue
usePrevious Returns the value a component held on its previous committed render. @isudev/gutenberg/hooks/usePrevious
useResponsiveAttribute Reads and writes one logical setting across a breakpoint set, resolving the cascade so a control always has the right own value, inherited value and override state for whichever breakpoint is active. @isudev/gutenberg/hooks/useResponsiveAttribute