Skip to content

feat: update to Storybook 11 - #931

Merged
dannyhw merged 4 commits into
nextfrom
chore/storybook-v11
Oct 21, 2026
Merged

dannyhw merged 4 commits into
nextfrom
chore/storybook-v11

Conversation

@dannyhw

@dannyhw dannyhw commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Updates every Storybook dependency to 11.0.0-alpha.6 (the current next on npm) and ports @storybook/react-native to the Storybook 11 API changes.

Dependencies

  • Ran pnpm update-storybook-deps --version ^11.0.0-alpha.6 to update storybook, @storybook/react and @storybook/react-native-web-vite across packages and examples. @storybook/mcp and @storybook/addon-react-native-server are skipped by the script's ignore list.
  • Moved the storybook peer range (and @storybook/react for the notes addon) to ^11.0.0-alpha.6. The script doesn't touch peers.

Story sorting: storySort in preview → storySorts in main

Storybook 11 no longer reads parameters.options.storySort from preview. Sorting is configured with a storySorts array in main instead, where each sorter only orders the stories the sorters before it consider equal. This PR matches that: preview storySort is no longer read, with no fallback or warning, same as core. Users can run npx storybook automigrate story-sort-to-main --config-dir .rnstorybook, which I checked works on an RN config.

  • main.storySorts is supported as an array or as a preset function.
  • New sortIndexEntries helper shared by prepareStories (device) and buildIndex (Metro / channel server / MCP). Core doesn't export combineStorySorts, so this calls core's sortStoriesV7 once per sorter, as stable sorts from last to first, which gives the same order.
  • Divergence from core: core sorts on the server, so comparators never leave Node. On device the app builds its own index at runtime, so the generator serializes storySorts into storybook.requires and passes it to start() / updateView(). Objects and arrays are written as JSON and functions as source text, so comparators can't reference anything outside their own body. Other options considered: plain values only, bundling main, sorting at generate time, or asking the channel server for the index. Each breaks offline use, stories added during a session, or core's comparator support.
  • Addon preset sorters (presets.apply('storySorts')) aren't collected. On-device addons don't go through core presets.
  • The examples, docs and MIGRATION.md now use storySorts in main.

CSF factories types

Meta's second type parameter in storybook/internal/csf changed from the meta annotations to a union of meta arg keys. RNPreview / RNMeta / RNStory now mirror Storybook 11's ReactPreview / ReactMeta / ReactStory and use the new MetaInput, MetaTypes, StoryArgs and TypedMetaArgKeys helpers. They also gain meta.type<T>().

Controls

InputType.defaultValue is now typed never, so controlArgTypes.ts casts the local ArgType to InputType when calling includeConditionalArg.

Testing

  • pnpm build, pnpm check:types, pnpm format:check, eslint on the changed files, and pnpm --filter expo-example check (which type-checks the factory stories) all pass.
  • pnpm test passes. New coverage:
    • sortStories.test.ts: the chaining is checked against core's own comparators, captured from sortStoriesV7, combined with a copy of core's combineStorySorts on random story sets.
    • storySorts.test.ts: start() / updateView() sort the device index, including stories added on update, and ignore preview storySort.
    • tests/scripts/generate.test.ts: the emitted storySorts is evaluated and round-trips objects, nested orders, quoted strings, arrow / named / multi-line functions and preset functions. The typed .ts output passes a strict type check, and nothing is emitted without storySorts.
    • tests/scripts/buildIndex.test.ts: array, preset function, and no sorters with preview storySort ignored.
  • Not tested on a device or simulator yet.

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 872ab39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@storybook/react-native Patch
@storybook/addon-ondevice-actions Patch
@storybook/addon-ondevice-backgrounds Patch
@storybook/addon-ondevice-controls Patch
@storybook/addon-ondevice-notes Patch
@storybook/react-native-theming Patch
@storybook/react-native-ui-common Patch
@storybook/react-native-ui-lite Patch
@storybook/react-native-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dannyhw
dannyhw force-pushed the chore/storybook-v11 branch from 4ad50b0 to 872ab39 Compare October 21, 2026 18:44
@dannyhw
dannyhw merged commit daf48e2 into next Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants