Skip to content

Commit

Permalink
React native: Emit event when story is rendered (#7449)
Browse files Browse the repository at this point in the history
React native: Emit event when story is rendered
  • Loading branch information
shilman authored Jul 18, 2019
2 parents 291bf23 + aff037b commit 97b07f9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/react-native/src/preview/components/StoryView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export default class StoryView extends Component<Props> {
channel.on(Events.FORCE_RE_RENDER, this.forceReRender);
}

componentDidUpdate() {
const channel = addons.getChannel();
const { stories } = this.props;
const { storyId } = stories.getSelection();

if (storyId) {
channel.emit(Events.STORY_RENDERED);
}
}

componentWillUnmount() {
const channel = addons.getChannel();
channel.removeListener(Events.STORY_RENDER, this.forceReRender);
Expand Down

0 comments on commit 97b07f9

Please sign in to comment.