Skip to content

Commit

Permalink
fix: hook into SET_CURRENT_STORY for storybook 5
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 1, 2020
1 parent 2b98de8 commit f0d725b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions misc/storybook-custom-docs/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import addons from '@storybook/addons';
import { SET_CURRENT_STORY } from '@storybook/core-events';
import { ConfigApi } from '@storybook/client-api';
import { UPDATE_STORY_CONTEXT } from './types';
export * from './types';
Expand Down Expand Up @@ -53,10 +54,13 @@ export const useStoryId = () => {
setStoryId(id);
}
};

channel.on(SET_CURRENT_STORY, onStoryChange);
channel.on(UPDATE_STORY_CONTEXT, onStoryChange);

return () => {
channel.off(UPDATE_STORY_CONTEXT, onStoryChange);
channel.off(SET_CURRENT_STORY, onStoryChange);
};
}, [channel]);
return storyId;
Expand Down

0 comments on commit f0d725b

Please sign in to comment.