diff --git a/addons/knobs/src/components/Panel.js b/addons/knobs/src/components/Panel.js
index 5682dd30e523..c9e894752819 100644
--- a/addons/knobs/src/components/Panel.js
+++ b/addons/knobs/src/components/Panel.js
@@ -57,10 +57,15 @@ export default class Panel extends React.Component {
this.loadedFromUrl = false;
this.props.channel.on('addon:knobs:setKnobs', this.setKnobs);
this.props.channel.on('addon:knobs:setOptions', this.setOptions);
+
+ this.stopListeningOnStory = this.props.api.onStory(() => {
+ this.setState({ knobs: [] });
+ });
}
componentWillUnmount() {
this.props.channel.removeListener('addon:knobs:setKnobs', this.setKnobs);
+ this.stopListeningOnStory();
}
setOptions(options = { debounce: false, timestamps: false }) {
@@ -155,6 +160,7 @@ Panel.propTypes = {
}).isRequired,
onReset: PropTypes.object, // eslint-disable-line
api: PropTypes.shape({
+ onStory: PropTypes.func,
getQueryParam: PropTypes.func,
setQueryParams: PropTypes.func,
}).isRequired,
diff --git a/addons/knobs/src/react/WrapStory.js b/addons/knobs/src/react/WrapStory.js
index a23227978022..29568e2950ad 100644
--- a/addons/knobs/src/react/WrapStory.js
+++ b/addons/knobs/src/react/WrapStory.js
@@ -33,10 +33,6 @@ export default class WrapStory extends React.Component {
this.props.channel.removeListener('addon:knobs:knobChange', this.knobChanged);
this.props.channel.removeListener('addon:knobs:reset', this.resetKnobs);
this.props.knobStore.unsubscribe(this.setPaneKnobs);
-
- // cleanup before leaving
- this.props.knobStore.reset();
- this.setPaneKnobs(false);
}
setPaneKnobs(timestamp = +new Date()) {
diff --git a/addons/knobs/src/vue/index.js b/addons/knobs/src/vue/index.js
index 0b653f7c71c1..1c76ff5fcb72 100644
--- a/addons/knobs/src/vue/index.js
+++ b/addons/knobs/src/vue/index.js
@@ -1,7 +1,6 @@
export const vueHandler = (channel, knobStore) => getStory => context => ({
render(h) {
- const story = getStory(context);
- return h(typeof story === 'string' ? { template: story } : story);
+ return h(getStory(context));
},
methods: {
@@ -31,10 +30,8 @@ export const vueHandler = (channel, knobStore) => getStory => context => ({
},
beforeDestroy(){
- console.log('beforeDestroy');
channel.removeListener('addon:knobs:reset', this.onKnobReset);
channel.removeListener('addon:knobs:knobChange', this.onKnobChange);
knobStore.unsubscribe(this.setPaneKnobs);
- this.onKnobReset();
}
});
\ No newline at end of file
diff --git a/app/vue/src/client/preview/render.js b/app/vue/src/client/preview/render.js
index 653cf9ea362d..937674e3172f 100644
--- a/app/vue/src/client/preview/render.js
+++ b/app/vue/src/client/preview/render.js
@@ -96,8 +96,7 @@ export function renderMain(data, storyStore) {
app = new Vue({
el: '#root',
render(h) {
- const story = typeof element === 'string' ? { template: element } : element;
- return h('div', {attrs: { id: 'root' } }, [h(story)]);
+ return h('div', {attrs: { id: 'root' } }, [h(element)]);
},
});
}
diff --git a/examples/cra-kitchen-sink/src/stories/index.js b/examples/cra-kitchen-sink/src/stories/index.js
index 2c63eaccfd64..3a5dbb5498ce 100644
--- a/examples/cra-kitchen-sink/src/stories/index.js
+++ b/examples/cra-kitchen-sink/src/stories/index.js
@@ -7,7 +7,6 @@ import { addonNotes, WithNotes } from '@storybook/addon-notes';
import { withKnobs, addonKnobs, text, number } from '@storybook/addon-knobs';
import { linkTo } from '@storybook/addon-links';
import WithEvents from '@storybook/addon-events';
-import { withKnobs, text, number } from '@storybook/addon-knobs';
import centered from '@storybook/addon-centered';
import Button from '@storybook/components/dist/demo/Button';
diff --git a/examples/vue/src/stories/index.js b/examples/vue/src/stories/index.js
index d44bd989ad96..899d759cd909 100644
--- a/examples/vue/src/stories/index.js
+++ b/examples/vue/src/stories/index.js
@@ -14,7 +14,9 @@ import MyButton from './Button.vue';
storiesOf('Button', module)
// Works if Vue.component is called in the config.js in .storybook
- .add('story as a function template', () => '
🤔😳😯😮
') + .add('button with emoji', () => ({ + template: '' + })) + .add('p with emoji', () => ({ + template: '🤔😳😯😮
' + })) .add('colorful', () => ({ render(h) { return h(MyButton, { props: { color: 'pink' } }, ['colorful']); @@ -78,7 +84,9 @@ storiesOf('Other', module) storiesOf('Addon Notes', module) - .add('with some emoji', addonNotes({notes: 'My notes on emojies'})(() => '🤔😳😯😮
')) + .add('with some emoji', addonNotes({notes: 'My notes on emojies'})(() => ({ + template: '🤔😳😯😮
' + }))) .add('with some button', addonNotes({ notes: 'My notes on some button' })(() => ({ components: { MyButton }, template: '