Skip to content

fix: restore docgen auto argTypes (wrong @storybook/react entry point)#903

Open
ndelangen wants to merge 2 commits into
nextfrom
fix/docgen-argtypes-entry-point
Open

fix: restore docgen auto argTypes (wrong @storybook/react entry point)#903
ndelangen wants to merge 2 commits into
nextfrom
fix/docgen-argtypes-entry-point

Conversation

@ndelangen

@ndelangen ndelangen commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Auto-generated controls from a component's TypeScript props (docgen) were silently broken in on-device Storybook. Stories that relied on __docgenInfo (no hand-written argTypes) showed no controls — or, where core value-inference kicked in, every prop rendered as a plain text field (enums never became radios, booleans/colors were lost).

Root cause: packages/react-native/src/preview.ts imported argTypesEnhancers and parameters.docs.extractArgTypes from @storybook/react/entry-preview-docs, but those symbols are exported from @storybook/react/entry-preview-argtypes. The old import resolved to undefined, so the docgen argTypesEnhancer (enhanceArgTypes) never ran. Manual-argTypes stories kept working, which masked the regression.

-} from '@storybook/react/entry-preview-docs';
+} from '@storybook/react/entry-preview-argtypes';

Why this is the right fix

  • entry-preview-docs exports only applyDecorators, decorators, parameters (and parameters.docs only has story). argTypesEnhancers and extractArgTypes live in entry-preview-argtypes.
  • This is not a canary/experimentalDocgenServer issue. The entry-point layout is identical in the stable release this repo targets (@storybook/react@10.4.x) and back through 9.x; auto-docgen had been quietly broken on stable, independent of any canary.
  • No back-compat fallback is needed: entry-preview-argtypes exists across RN's supported Storybook range (peer dep >=10; present since v10.0.0).

Two red herrings ruled out during investigation

Test plan

  • Added a regression unit test (packages/react-native/src/preview.test.ts) asserting preview.argTypesEnhancers is a non-empty array of functions and preview.parameters.docs.extractArgTypes is a function. It fails against the old entry-preview-docs import (both undefined) and passes with the fix.
  • Manual end-to-end validation on stable @storybook/react@10.4.6 (no canary): a component-only story produced full auto controls, including a docgen-only size radio (small | medium | large) — a value set that only exists in the TS union type, so it can only come from docgen.

Changeset

Patch (@storybook/react-native), which bumps the fixed package group.

Here's a screenshot of the correct controls due to properly injected __docgenInfo:
Screenshot 2026-06-24 at 09 17 55
This was taken form an isolated example, which had it's node_modules patched with the fix this PR contains.

`argTypesEnhancers` and `parameters.docs.extractArgTypes` are exported from
`@storybook/react/entry-preview-argtypes`, not `entry-preview-docs`. The old
import resolved to `undefined`, silently disabling docgen-based auto controls
(only core value inference remained). Adds a regression test asserting both
are wired, plus a patch changeset.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings June 24, 2026 07:56
@ndelangen ndelangen requested a review from dannyhw as a code owner June 24, 2026 07:56
@ndelangen ndelangen requested a review from dannyhw June 24, 2026 07:56
@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 341ff27

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/react-native-ui Patch
@storybook/react-native-ui-lite Patch
@storybook/react-native-ui-common Patch
@storybook/react-native-theming Patch
@storybook/addon-ondevice-actions Patch
@storybook/addon-ondevice-backgrounds Patch
@storybook/addon-ondevice-controls Patch
@storybook/addon-ondevice-notes 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores TypeScript-prop docgen–driven auto-generated controls (argTypes) in on-device Storybook by importing the correct Storybook React preview entry point, and adds a regression test to prevent the issue from recurring.

Changes:

  • Switch packages/react-native/src/preview.ts to import argTypesEnhancers and parameters.docs.extractArgTypes from @storybook/react/entry-preview-argtypes (instead of entry-preview-docs).
  • Add a regression unit test asserting preview.argTypesEnhancers and preview.parameters.docs.extractArgTypes are correctly wired.
  • Add a patch changeset for @storybook/react-native.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/react-native/src/preview.ts Fixes docgen argTypes wiring by using the correct @storybook/react preview entry point.
packages/react-native/src/preview.test.ts Adds regression coverage to ensure docgen-related preview exports aren’t undefined.
.changeset/fix-docgen-argtypes-entry-point.md Publishes the fix as a patch release for @storybook/react-native.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this test adds much value TBH, it only really covers the very specific scenario where we change the entry point structure of @storybook/react/entry-preview-argtypes. An E2E tests that actually checks for the proper existence of the controls seems a lot more useful here, but I can understand if that is impossible to write in practice.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish writing e2e tests for RN were as simple as spinning up a playwright instance, but unfortunately, we do not have the infrastructure set up to do this right now.

I agree the test is far from optimal, but it's likely better than not having one.

@dannyhw dannyhw Jun 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can typescript not provide the validation for the import existing? this seems like it would validate in the same way or at least it should

Comment thread packages/react-native/src/preview.ts Outdated
Comment thread packages/react-native/src/preview.ts Outdated
Co-authored-by: Norbert de Langen <ndelangen@me.com>
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.

4 participants