mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 08:01:20 +08:00
CLEANUP channel should not be used in manager, just use api instead
This commit is contained in:
parent
2887028ad2
commit
5b11460c6a
@ -44,9 +44,9 @@ export default class StoryPanel extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
const { channel } = this.props;
|
const { api } = this.props;
|
||||||
|
|
||||||
channel.on(EVENT_ID, this.listener);
|
api.on(EVENT_ID, this.listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
@ -56,9 +56,9 @@ export default class StoryPanel extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
const { channel } = this.props;
|
const { api } = this.props;
|
||||||
|
|
||||||
channel.removeListener(EVENT_ID, this.listener);
|
api.off(EVENT_ID, this.listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedStoryRef = ref => {
|
setSelectedStoryRef = ref => {
|
||||||
@ -181,10 +181,8 @@ StoryPanel.propTypes = {
|
|||||||
active: PropTypes.bool.isRequired,
|
active: PropTypes.bool.isRequired,
|
||||||
api: PropTypes.shape({
|
api: PropTypes.shape({
|
||||||
selectStory: PropTypes.func.isRequired,
|
selectStory: PropTypes.func.isRequired,
|
||||||
}).isRequired,
|
|
||||||
channel: PropTypes.shape({
|
|
||||||
emit: PropTypes.func,
|
emit: PropTypes.func,
|
||||||
on: PropTypes.func,
|
on: PropTypes.func,
|
||||||
removeListener: PropTypes.func,
|
off: PropTypes.func,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
@ -1,17 +1,15 @@
|
|||||||
|
/* eslint-disable react/prop-types */
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import addons from '@storybook/addons';
|
import addons from '@storybook/addons';
|
||||||
|
|
||||||
import StoryPanel from './StoryPanel';
|
import StoryPanel from './StoryPanel';
|
||||||
import { ADDON_ID, PANEL_ID } from '.';
|
import { ADDON_ID, PANEL_ID } from '.';
|
||||||
|
|
||||||
export function register() {
|
export function register() {
|
||||||
addons.register(ADDON_ID, api => {
|
addons.register(ADDON_ID, api => {
|
||||||
const channel = addons.getChannel();
|
|
||||||
addons.addPanel(PANEL_ID, {
|
addons.addPanel(PANEL_ID, {
|
||||||
title: 'Story',
|
title: 'Story',
|
||||||
// eslint-disable-next-line react/prop-types
|
render: ({ active, key }) => <StoryPanel key={key} api={api} active={active} />,
|
||||||
render: ({ active, key }) => (
|
|
||||||
<StoryPanel key={key} channel={channel} api={api} active={active} />
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user