No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

The component failed to render properly, likely due to a configuration issue in Storybook. Here are some common causes and how you can address them:

  1. Missing Context/Providers: You can use decorators to supply specific contexts or providers, which are sometimes necessary for components to render correctly. For detailed instructions on using decorators, please visit the Decorators documentation.
  2. Misconfigured Webpack or Vite: Verify that Storybook picks up all necessary settings for loaders, plugins, and other relevant parameters. You can find step-by-step guides for configuring Webpack or Vite with Storybook.
  3. Missing Environment Variables: Your Storybook may require specific environment variables to function as intended. You can set up custom environment variables as outlined in the Environment Variables documentation.

useResizeObserver

Use case

Hook that is great for registering a callback that will be called if an associated node is resized. Uses the ResizeObserver API.

How to install

yarn add @bedrock-layout/use-resize-observer

Basic usage

useResizeObserver takes a callback that accepts a ResizeObserverEntry and will return a ref object to assign the appropriate node.

import { useResizeObserver } from '@bedrock-layout/use-resize-observer'; function Component(props){ const ref = useResizeObserver((entry) => { /* do something with entry */ }) return <div ref={ref} {...props}> }

Optionally, if you already have a node from a ref you are using you can pass it in as a second argument. Note: If you choose to use it this way, the node must be stateful either by using @bedrock-layout/use-stateful-ref or using a React.useState hook with the ref. If you are using the returned ref object, the node passed in will be ignored.

import { useResizeObserver } from '@bedrock-layout/use-resize-observer'; import { useStatefulRef } from '@bedrock-layout/use-stateful-ref'; function Component(props){ const statefulRef = useStatefulRef() const ref = useResizeObserver((entry) => { /* do something with entry */ }, statefulRef.current) return <div ref={statefulRef} {...props}> }