Skip to content

Commit

Permalink
Add deprecation note + pass through loadStory
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jan 14, 2024
1 parent 4821d82 commit a21ac32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 11 additions & 5 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
- [Canvas Doc block properties](#canvas-doc-block-properties)
- [`Primary` Doc block properties](#primary-doc-block-properties)
- [`createChannel` from `@storybook/postmessage` and `@storybook/channel-websocket`](#createchannel-from-storybookpostmessage-and--storybookchannel-websocket)
- [StoryStore methods deprecated](#storystore-methods-deprecated)
- [StoryStore and methods deprecated](#storystore-and-methods-deprecated)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -978,11 +978,17 @@ The `name` prop is now removed in favor of the `of` property. [More info](#doc-b
The `createChannel` APIs from both `@storybook/channel-websocket` and `@storybook/postmessage` are now removed. Please use `createBrowserChannel` instead, from the `@storybook/channels` package.

Additionally, the `PostmsgTransport` type is now removed in favor of `PostMessageTransport`.
#### StoryStore methods deprecated

The following methods on the `StoryStore` are deprecated and will be removed in 9.0:
- `store.fromId()` - please use `store.loadStory()` instead.
- `store.raw()` - please use `store.extract()` instead.

#### StoryStore and methods deprecated

The StoryStore (`__STORYBOOK_STORY_STORE__` and `__STORYBOOK_PREVIEW__.storyStore`) are deprecated, and will no longer be accessible in Storybook 9.0.

In particular, the following methods on the `StoryStore` are deprecated and will be removed in 9.0:
- `store.fromId()` - please use `preview.loadStory({ storyId })` instead.
- `store.raw()` - please use `preview.extract()` instead.

Note that both these methods require initialization, so you should await `preview.ready()`.

## From version 7.5.0 to 7.6.0

Expand Down
7 changes: 7 additions & 0 deletions code/lib/preview-api/src/modules/preview-web/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ export class Preview<TRenderer extends Renderer> {
}

// API
async loadStory({ storyId }: { storyId: StoryId }) {
if (!this.storyStoreValue)
throw new CalledPreviewMethodBeforeInitializationError({ methodName: 'loadStory' });

return this.storyStoreValue.loadStory({ storyId });
}

async extract(options?: { includeDocsOnly: boolean }) {
if (!this.storyStoreValue)
throw new CalledPreviewMethodBeforeInitializationError({ methodName: 'extract' });
Expand Down

0 comments on commit a21ac32

Please sign in to comment.