storybook-react-context
Version:
Manipulate React context inside Storybook. Read state and dispatch updates from outside of React component.
18 lines (17 loc) • 692 B
TypeScript
import React from 'react';
import { makeDecorator } from 'storybook/preview-api';
type StoryContext = Parameters<Parameters<typeof makeDecorator>[0]['wrapper']>[1];
export type ContextOptions<T = unknown> = {
contextValue: (context: StoryContext) => T;
context: React.Context<T>;
};
export interface DecoratorOptions extends Partial<ContextOptions> {
contexts?: ContextOptions[];
}
type ContextValuesProps = {
children: (contextValues: unknown[]) => React.ReactNode;
contexts: ContextOptions[];
};
export declare const ContextValues: ({ children, contexts }: ContextValuesProps) => React.ReactNode;
export declare const withReactContext: (...args: any) => any;
export {};