Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storybook/store

Package Overview
Dependencies
Maintainers
28
Versions
589
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/store

The store is reponsible for loading a story from a CSF file and preparing into a `Story` type, which is our internal format.

  • 6.4.0-beta.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-17.5%
Maintainers
28
Weekly downloads
 
Created

What is @storybook/store?

@storybook/store is a package that provides the core state management functionality for Storybook. It helps manage the state of stories, including their parameters, args, globals, and more. This package is essential for maintaining the state consistency and reactivity of Storybook's UI components.

What are @storybook/store's main functionalities?

State Management

This feature allows you to create and manage the state of your stories, including their parameters, args, and globals. The code sample demonstrates how to create a store, set its state, and retrieve the current state.

import { createStore } from '@storybook/store';

const store = createStore({
  stories: {},
  parameters: {},
  args: {},
  globals: {}
});

store.setState({
  stories: { 'example-story': { id: 'example-story', name: 'Example Story' } },
  args: { 'example-story': { arg1: 'value1' } }
});

console.log(store.getState());

Reactive State Updates

This feature allows you to subscribe to state changes and react to updates. The code sample demonstrates how to subscribe to state changes and log the updated state whenever it changes.

import { createStore } from '@storybook/store';

const store = createStore({
  stories: {},
  parameters: {},
  args: {},
  globals: {}
});

store.subscribe((state) => {
  console.log('State updated:', state);
});

store.setState({
  args: { 'example-story': { arg1: 'new-value' } }
});

Parameter Management

This feature allows you to manage parameters for your stories. The code sample demonstrates how to set parameters for a story and retrieve them from the store.

import { createStore } from '@storybook/store';

const store = createStore({
  stories: {},
  parameters: {},
  args: {},
  globals: {}
});

store.setState({
  parameters: { 'example-story': { param1: 'value1' } }
});

console.log(store.getState().parameters);

Other packages similar to @storybook/store

Keywords

FAQs

Package last updated on 18 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc