File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
examples/expo-example/components/StoryName
packages/react-native/src Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change
1
+ import type { Meta , StoryObj } from '@storybook/react-native' ;
2
+ import { Text } from 'react-native' ;
3
+
4
+ const StoryName = ( { name } : { name : string } ) => < Text > { name } </ Text > ;
5
+
6
+ const meta = {
7
+ component : StoryName ,
8
+ } satisfies Meta < typeof StoryName > ;
9
+
10
+ export default meta ;
11
+
12
+ type Story = StoryObj < typeof meta > ;
13
+
14
+ export const WithStoryName : Story = {
15
+ storyName : 'story name here' ,
16
+ args : {
17
+ name : 'story name here' ,
18
+ } ,
19
+ } ;
20
+
21
+ export const WithName : Story = {
22
+ storyName : 'name here' ,
23
+ args : {
24
+ name : 'name here' ,
25
+ } ,
26
+ } ;
27
+
28
+ export const WithNoName : Story = {
29
+ args : {
30
+ name : 'no name here' ,
31
+ } ,
32
+ } ;
33
+
34
+ export const CSF2Example = ( args : { name : string } ) => < StoryName { ...args } /> ;
35
+ CSF2Example . args = { name : 'csf2 with no name' } ;
36
+
37
+ export const CSF2ExampleWithName = ( args : { name : string } ) => < StoryName { ...args } /> ;
38
+ CSF2ExampleWithName . storyName = 'csf2 with name' ;
39
+ CSF2ExampleWithName . args = { name : 'csf2 with name' } ;
Original file line number Diff line number Diff line change @@ -125,7 +125,13 @@ export function prepareStories({
125
125
const nameFromExport = storyNameFromExport ( key ) ;
126
126
const id = toId ( title , nameFromExport ) ;
127
127
128
- const name = exportValue ?. name || exportValue ?. storyName || nameFromExport ;
128
+ let name = nameFromExport ;
129
+
130
+ if ( typeof exportValue === 'function' ) {
131
+ name = exportValue ?. storyName || nameFromExport ;
132
+ } else {
133
+ name = exportValue ?. name || exportValue ?. storyName || nameFromExport ;
134
+ }
129
135
130
136
index . entries [ id ] = {
131
137
type : 'story' ,
You can’t perform that action at this time.
0 commit comments