Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preact: Fix hooks when used in stories, preact-kitchen-sink #14473

Merged
merged 16 commits into from
Apr 8, 2021

Conversation

KrofDrakula
Copy link
Member

@KrofDrakula KrofDrakula commented Apr 4, 2021

Issue: #13928.

Also resolves #11145 as it fixes Preact 10.x snapshots.

What I did

  • Upgraded dev version of preact to 10.x on the preact kitchen sink app to match the dev dependency installed.
  • Changed from preact-render-to-json to preact-render-to-string for rendering Jest snapshots in tests.
  • Changed client/preview/render.tsx to render stories using h() so that hooks work.
  • Changed storyshots-core/src/frameworks/preact/renderTree.ts to use preact-render-to-string with pretty: ' ' to output sensible HTML for snapshots.

How to test

  • Is this testable with Jest or Chromatic screenshots? ✔ The stories stopped rendering when the devDependencies on Storybook were upgraded to 10.x but the kitchen sink app was kept as 8.x. Not sure if the preact kitchen sink app is currently being checked, but it will render now.
  • Does this need a new example in the kitchen sink apps? ✔ The Addons > Actions > Action only story has been updated to use a state hook to demonstrate that issue Storybook Preact story rendering breaks when using hooks to declare state in stories #13928 is fixed.
  • Does this need an update to the documentation? ❌ It should still work for existing apps that pull @storybook/preact from npm since the runtime version of Storybook uses the consumer's version of preact, whichever is installed.

@shilman shilman changed the title Fix preact hooks when used in Storybook stories Preact: Fix hooks when used in stories, preact-kitchen-sink Apr 5, 2021
@KrofDrakula KrofDrakula self-assigned this Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storybook Preact story rendering breaks when using hooks to declare state in stories
2 participants