useGetPuck

A hook for accessing the latest PuckApi outside of the React render lifecycle.

import { useGetPuck } from "@measured/puck";
 
const Example = () => {
  const getPuck = useGetPuck();
 
  const handleClick = useCallback(() => {
    // Current PuckApi is always provided
    const { appState } = getPuck();
  }, [getPuck]);
 
  return <button onClick={handleClick}>Click me</button>;
};

If you need to react to changes to PuckApi, try the usePuck hook.

Returns

The latest PuckApi data.