Skip to content

Commit

Permalink
Merge pull request storybookjs#14444 from j3rem1e/issue-14443
Browse files Browse the repository at this point in the history
Revert "Svelte - Fix async loaders and docs" Fix storybookjs#14443
  • Loading branch information
shilman authored Apr 2, 2021
2 parents 74dce67 + 2decf47 commit 79c1c52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 66 deletions.
9 changes: 4 additions & 5 deletions addons/docs/src/frameworks/svelte/HOC.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script>
export let storyContext;
export let unboundStoryFn;
let { Component: component, props } = unboundStoryFn(storyContext);
export let storyFn;
let { Component: component, props } = storyFn();
</script>

<svelte:component this={component} {...props}/>
<svelte:component this={component} {...props}/>
32 changes: 8 additions & 24 deletions addons/docs/src/frameworks/svelte/prepareForInline.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
import { StoryContext, StoryFn } from '@storybook/addons';
import { StoryFn } from '@storybook/addons';

import React from 'react';

// @ts-ignore
import HOC from './HOC.svelte';

export const prepareForInline = (storyFn: StoryFn, context: StoryContext) => {
export const prepareForInline = (storyFn: StoryFn) => {
const el = React.useRef(null);
React.useEffect(() => {
let cancelled = false;
const { applyLoaders, unboundStoryFn } = context;

let cpn: any;

applyLoaders().then((storyContext: StoryContext) => {
if (!cancelled) {
cpn = new HOC({
target: el.current,
props: {
storyContext,
unboundStoryFn,
},
});
}
const root = new HOC({
target: el.current,
props: {
storyFn,
},
});

return () => {
cancelled = true;
if (cpn) {
cpn.$destroy();
}
};
return () => root.$destroy();
});

return React.createElement('div', { ref: el });
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions examples/svelte-kitchen-sink/src/stories/loaders.stories.js

This file was deleted.

0 comments on commit 79c1c52

Please sign in to comment.