Skip to content

Commit f8e3b54

Browse files
committed
fix: CalledPreviewMethodBeforeInitializationError
1 parent 1d62ad1 commit f8e3b54

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/react-native/src/View.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ export class View {
148148
};
149149

150150
createPreparedStoryMapping = async () => {
151-
await Promise.all(
152-
Object.keys(this._storyIndex.entries).map(async (storyId: StoryId) => {
153-
this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
154-
})
151+
await this._preview.storeInitializationPromise.then(() =>
152+
Promise.all(
153+
Object.keys(this._storyIndex.entries).map(async (storyId: StoryId) => {
154+
this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
155+
})
156+
)
155157
);
156158
};
157159

@@ -178,7 +180,9 @@ export class View {
178180
this._preview.channel = channel;
179181
this._preview.setupListeners();
180182
channel.emit(Events.CHANNEL_CREATED);
181-
this._preview.initializeWithStoryIndex(this._storyIndex);
183+
this._preview.storeInitializationPromise.then(() =>
184+
this._preview.initializeWithStoryIndex(this._storyIndex)
185+
);
182186
}
183187

184188
managerAddons.loadAddons({

0 commit comments

Comments
 (0)