Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-docgen-argtypes-entry-point.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@storybook/react-native": patch
---

Fix docgen-based auto argTypes (controls) that were silently disabled. `preview.ts` imported `argTypesEnhancers` and `parameters.docs.extractArgTypes` from `@storybook/react/entry-preview-docs`, which does not export them, so both resolved to `undefined`. They are now imported from `@storybook/react/entry-preview-argtypes`, restoring auto-generated controls from component `__docgenInfo`.
20 changes: 20 additions & 0 deletions packages/react-native/src/preview.test.ts

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import preview from './preview';

// Regression test for the entry-point bug where `argTypesEnhancers` and
// `parameters.docs.extractArgTypes` were imported from
// `@storybook/react/entry-preview-docs` — which does not export them, so both
// resolved to `undefined` and docgen-based auto argTypes were silently disabled.
// They are exported from `@storybook/react/entry-preview-argtypes`.
describe('preview docgen wiring', () => {
it('wires argTypesEnhancers from @storybook/react', () => {
expect(Array.isArray(preview.argTypesEnhancers)).toBe(true);
expect(preview.argTypesEnhancers?.length).toBeGreaterThan(0);
preview.argTypesEnhancers?.forEach((enhancer) => {
expect(typeof enhancer).toBe('function');
});
});

it('wires parameters.docs.extractArgTypes from @storybook/react', () => {
expect(typeof preview.parameters?.docs?.extractArgTypes).toBe('function');
});
});
6 changes: 5 additions & 1 deletion packages/react-native/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Platform } from 'react-native';
// `argTypesEnhancers` and `parameters.docs.extractArgTypes` are exported from the
// `entry-preview-argtypes` entry point, not `entry-preview-docs`. Importing them
Comment thread
dannyhw marked this conversation as resolved.
Outdated
// from `entry-preview-docs` resolves to `undefined`, which silently disables
// docgen-based auto argTypes (controls then only come from core value inference).
Comment thread
ndelangen marked this conversation as resolved.
Outdated
import {
parameters as reactParameters,
argTypesEnhancers,
} from '@storybook/react/entry-preview-docs';
} from '@storybook/react/entry-preview-argtypes';
import { type Preview } from '@storybook/react';

// Workaround for Reanimated globals not being available on web.
Expand Down