Skip to content

[Add on: Viewport] How should I reset viewport between stories? #26667

Closed Answered by lancegliser
lancegliser asked this question in Help
Discussion options

You must be logged in to vote

Forgot I'd posted this. A came on a solution a while ago with the advent of initialGlobals for viewport in preview.tsx.

const preview: Preview = {
  parameters: {
    initialGlobals: {
      viewport: { value: undefined },
    },
  },
}

My stories now just do this:

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
const meta: Meta<typeof ErrorGraphic> = {
  component: ErrorGraphic,
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
  tags: ["autodocs"],
  parameters: {
    // More on Story layout: https://storybook.js.org/docs/react/config…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@lancegliser
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lancegliser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants