1

Hi i am working on storybook where i need to pass default data to component from storybook,i am trying to pass data using args and not able to get in state in components.below is my storybook.

const Template = (args) => (
  <State>
    <Confirmation {...args} />
  </State>
);

const story = {
  component: Confirmation,
  title: "Confirmation",
};

export default story;

export const Default = Template.bind({});
Default.args = {
  search_request: {
    isTwoWay: true,
  }
}

in my component:

const Confirmation = ({ onClick, classes }) => {
  const { state } = useContext(StateContext);
 
 const isTwoWay = state.search_request.isTwoWay;

}

how to pass data to state from stories, any help please

Sudhir
  • 1
  • 1
  • 9
  • 24

1 Answers1

0

for that you should refer to your story declaration

import { Meta, Story } from '@storybook/react'
import React from 'react'

export default {
   title: 'Your story title',
   argTypes: {
     'search_request': {
     control: { type: 'boolean'},
     defaultValue: true
     }
   }
}
TBR920
  • 77
  • 7