0

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
  • 471
  • 1
  • 8
  • 19

1 Answers1

0

What I understand from your question is that you want to update the StateContext from your child component

This question has already be answered here:

How to update React Context from inside a child component?

Cotldus
  • 81
  • 3