I am using a mobx store to fetch the options for status. And before rendering the story I want to format the props.
Whenever that status is changed (using storybook control), I need to format the app data(which will be passed as the props to the component) before the storybook renders that story.
There are 2 question for me :
- Whether my code is correct ? Because the status is not going to be a prop rather the data will be prop. But I have assinged a argType for status.
- I can format the app data before it renders in 2 way one using the decorators and the other using the render. Both works as expected and so I am confused now, which is the appropriate or the permissible way to use, either the decorators or the render.
export default {
title: “Component/New",
component: Indicator,
argTypes: {
status: {
control: { type: "select" },
options: Object.keys(FlowStatus)
}
},
decorators: [
(Story, context) => {
const { store } = useStores();
const app = store.apps[0];
context.args.app = app;
return <Story app={getApp(app, context.args.Status)} />;
}
],
render: args => {
const { store } = useStores();
const app = store.apps[0];
return <Indicator app={getApp(app, args.Status} />;
}
};
export const Default = {
name: “New”
};