Skip to content

Commit

Permalink
fix: CalledPreviewMethodBeforeInitializationError (8.2) (#587)
Browse files Browse the repository at this point in the history
* fix: CalledPreviewMethodBeforeInitializationError

* fix: protected property access

* Revert "fix: protected property access"

This reverts commit fef8b08.

* fix: Cannot call initializeWithStoryIndex until project annotations resolve

---------

Co-authored-by: Daniel Williams <[email protected]>
  • Loading branch information
stevoland and dannyhw authored Sep 14, 2024
1 parent a349ec9 commit b1af9c7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/react-native/src/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,12 @@ export class View {
};

createPreparedStoryMapping = async () => {
await Promise.all(
Object.keys(this._storyIndex.entries).map(async (storyId: StoryId) => {
this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
})
await this._preview.ready().then(() =>
Promise.all(
Object.keys(this._storyIndex.entries).map(async (storyId: StoryId) => {
this._idToPrepared[storyId] = await this._preview.loadStory({ storyId });
})
)
);
};

Expand All @@ -178,7 +180,7 @@ export class View {
this._preview.channel = channel;
this._preview.setupListeners();
channel.emit(Events.CHANNEL_CREATED);
this._preview.initializeWithStoryIndex(this._storyIndex);
this._preview.ready().then(() => this._preview.onStoryIndexChanged());
}

managerAddons.loadAddons({
Expand Down

0 comments on commit b1af9c7

Please sign in to comment.