storybook-valtio-auto-bind
v1.0.2
Published
  [;
export default {
title: 'Example/Counter',
};
export const Counter = withStores(
{ counter: counterStore },
(args) => <button onClick={() => counterStore.count++}>{args.counter.count}</button>
);3. Observe Two-Way Binding
- Adjust the
countvalue in Storybook Controls. - Observe the changes reflected in the UI and the Valtio store.
API
withStores(stores, story)
stores: An object mapping store names to Valtio stores.story: The Storybook story function.
Decorators
ValtioStoreBindStory: Syncs Valtio store changes to Storybook args.StoryBindValtioStoreDecorator: Syncs Storybook args to Valtio stores.
Example
import { proxy } from 'valtio';
import { withStores } from 'storybook-valtio-auto-bind';
const store = proxy({ text: 'Hello, Storybook!' });
export const Example = withStores(
{ store },
(args) => <input value={args.store.text} onChange={(e) => (store.text = e.target.value)} />
);Acknowledgments
License
This project is licensed under the MIT License. See the LICENSE file for details.
