File tree Expand file tree Collapse file tree
app/react-native/src/preview Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,15 @@ export default class Preview {
5555 getStorybookUI ( params = { } ) {
5656 return ( ) => {
5757 let webUrl = null ;
58- let channel = addons . getChannel ( ) ;
58+ let channel = null ;
59+
60+ try {
61+ channel = addons . getChannel ( ) ;
62+ } catch ( e ) {
63+ // getChannel throws if the channel is not defined,
64+ // which is fine in this case (we will define it below)
65+ }
66+
5967 if ( params . resetStorybook || ! channel ) {
6068 const host = params . host || parse ( NativeModules . SourceCode . scriptURL ) . hostname ;
6169 const port = params . port !== false ? `:${ params . port || 7007 } ` : '' ;
Original file line number Diff line number Diff line change @@ -2,15 +2,19 @@ export class AddonStore {
22 constructor ( ) {
33 this . loaders = { } ;
44 this . panels = { } ;
5- // this.channel should get overwritten by setChannel if package versions are
6- // correct and AddonStore is a proper singleton. If not, this will be null
7- // (currently required by @storybook/react-native getStorybookUI)
85 this . channel = null ;
96 this . preview = null ;
107 this . database = null ;
118 }
129
1310 getChannel ( ) {
11+ // this.channel should get overwritten by setChannel if package versions are
12+ // correct and AddonStore is a proper singleton. If not, throw.
13+ if ( ! this . channel ) {
14+ throw new Error (
15+ 'Accessing nonexistent addons channel, see https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel'
16+ ) ;
17+ }
1418 return this . channel ;
1519 }
1620
You can’t perform that action at this time.
0 commit comments