File tree 3 files changed +13
-4
lines changed
code/ui/blocks/src/blocks
3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,6 @@ export const OfStringMetaAttached: Story = {
99
99
parameters : { relativeCsfPaths : [ '../examples/Button.stories' ] , attached : true } ,
100
100
} ;
101
101
export const Children : Story = {
102
- parameters : { relativeCsfPaths : [ '../examples/Button.stories' ] , attached : true } ,
102
+ parameters : { relativeCsfPaths : [ '../examples/Button.stories' ] , attached : false } ,
103
103
render : ( ) => < Subtitle > This subtitle is a string passed as a children</ Subtitle > ,
104
104
} ;
Original file line number Diff line number Diff line change @@ -25,8 +25,17 @@ export const Subtitle: FunctionComponent<SubtitleProps> = (props) => {
25
25
throw new Error ( 'Unexpected `of={undefined}`, did you mistype a CSF file reference?' ) ;
26
26
}
27
27
28
- const { preparedMeta } = useOf ( of || 'meta' , [ 'meta' ] ) ;
29
- const { componentSubtitle, docs } = preparedMeta . parameters || { } ;
28
+ let preparedMeta ;
29
+ try {
30
+ preparedMeta = useOf ( of || 'meta' , [ 'meta' ] ) . preparedMeta ;
31
+ } catch ( error ) {
32
+ if ( children && ! error . message . includes ( 'did you forget to use <Meta of={} />?' ) ) {
33
+ // ignore error about unattached CSF since we can still render children
34
+ throw error ;
35
+ }
36
+ }
37
+
38
+ const { componentSubtitle, docs } = preparedMeta ?. parameters || { } ;
30
39
31
40
if ( componentSubtitle ) {
32
41
deprecate (
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export const Title: FunctionComponent<TitleProps> = (props) => {
42
42
}
43
43
}
44
44
45
- const content = children || extractTitle ( preparedMeta . title ) ;
45
+ const content = children || extractTitle ( preparedMeta ? .title ) ;
46
46
47
47
return content ? < PureTitle className = "sbdocs-title sb-unstyled" > { content } </ PureTitle > : null ;
48
48
} ;
You can’t perform that action at this time.
0 commit comments