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.

useStatefulRef

React RefObjects are not stateful, or in other words, changing the current property on the RefObject doesn't trigger a rerender. One can use a ref callback to updated state, but now we are no longer using RefObjects and there is great power in consistency and knowing we will be getting a RefObject every time. useStatefulRef will return a RefObject that can be passed around and used just like any other RefObject, except that changes to the current property will trigger a rerender just like updating state.

Use case

Anytime you want a RefObject that will trigger a rerender when the current property is updated

How to install

npm install @bedrock-layout/use-stateful-ref

Basic usage

const App = () => { const ref = useStatefulRef(null); //... Use the ref object will trigger a rerender return <Div ref={ref}>{...content}</Div>; };