-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@storybook/vue@rc : addon-knobs creates and destroys story on knob update #4516
Comments
#4098 is also related |
In a v4 we do not have a separation in knobs to vue/angular/react/whatever. So we need a more generic solution. |
@igor-dv i'd be happy to help if i could get any pointers to a direction, but i feel it's a deep structural change that should probably come from the core team, right ? |
I think so =/ There is some discussion about changing knobs anyway. |
@igor-dv would you have any idea about a time to get a chance to see an alpha ? as for now, vue-play isn't supporting knobs and unmaintained for years, there's no options for Vue users, and i suspect it'll be the same for other frameworks. |
Can you please explain the problem behind the issue ? I understand that the component is recreated each time you change the knob, but sounds like it is still working. Regarding the alpha, there is no alpha yet, but discussion in Discord |
@igor-dv if the component is created and destroyed everytime, then all the variables initialized in the internal state of the component are going back to default and so is the same with all the children of this component. |
@igor-dv actually, my code and gif can a bit misleading. For the code, I'm using the knob in the Consider more import { storiesOf } from '@storybook/vue';
import { withKnobs, text, button } from '@storybook/addon-knobs';
storiesOf('Knobs demo', module)
.addDecorator(withKnobs)
.add('foobar', () => ({
template: '<span @click="i++">My name is {{ name }} and i am {{ i }} years old.</span>',
+ props: {
+ name: {
+ type: String,
+ default: text('name', 'John Doe'),
+ },
+ },
+
data() { return {
- name: text('name', 'John Doe'),
i: 40,
}; },
+ watch: {
+ i(val) {
+ console.log('i has changed to', val)
+ },
+ },
+
beforeCreate() {
- button('age me', () => this.i++)
+ button('age me', () => {
+ console.log('button knob has been triggered.')
+ this.i++
+ })
},
created() { console.log('created') },
destroyed() { console.log('destroyed') },
})); and you will have : In this gif you can see (in order) :
|
Released in 4.0.8. Can we close? |
Yep 💪 |
Step to reproduce :
npm i --save-dev @storybook/addon-knobs@rc
import '@storybook/addon-knobs/register';
to.storybook/addons.js
Expected result :
I can see the "created" log when i launch the story only
Actual result :
I can see the "created" and "destroyed" log everytime i modify the text value from the knob.
Additional comments :
It's related to [vue.js] [withKnobs] addon causes to re-create a new story at knobChange #3777 . As @ndelangen said it was working with v4 alphas, I wanted to try it myself to know if we could migrate our app.
Here's a repo and a gif screen-record of this bug :
The text was updated successfully, but these errors were encountered: