Skip to content

Commit

Permalink
Merge pull request #15409 from storybookjs/revert-15168-vue3-update-a…
Browse files Browse the repository at this point in the history
…rgs-without-remount

Revert "Vue3: Update args without re-mounting component"
  • Loading branch information
shilman committed Jun 29, 2021
2 parents c6d7323 + 005ae1a commit c2d2ca1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/vue3/src/client/preview/index.ts
Expand Up @@ -41,7 +41,7 @@ function prepare(rawStory: StoryFnVueReturnType, innerStory?: ConcreteComponent)

return {
render() {
return h(story, this.$root.storyArgs);
return h(story);
},
};
}
Expand Down
19 changes: 2 additions & 17 deletions app/vue3/src/client/preview/render.ts
@@ -1,28 +1,17 @@
import dedent from 'ts-dedent';
import { createApp, h, shallowRef, ComponentPublicInstance } from 'vue';
import { Args } from '@storybook/addons';
import { RenderContext, StoryFnVueReturnType } from './types';

const activeStoryComponent = shallowRef<StoryFnVueReturnType | null>(null);

interface Root extends ComponentPublicInstance {
storyArgs?: Args;
}

let root: Root | null = null;
let root: ComponentPublicInstance | null = null;

export const storybookApp = createApp({
// If an end-user calls `unmount` on the app, we need to clear our root variable
unmounted() {
root = null;
},

data() {
return {
storyArgs: undefined,
};
},

setup() {
return () => {
if (!activeStoryComponent.value)
Expand Down Expand Up @@ -59,13 +48,9 @@ export default function render({

showMain();

if (!forceRender) {
activeStoryComponent.value = element;
}
activeStoryComponent.value = element;

if (!root) {
root = storybookApp.mount('#root');
}

root.storyArgs = args;
}

0 comments on commit c2d2ca1

Please sign in to comment.