Skip to content

How to use useFlag in Storybook components? #9318

Closed Answered by JE4GLE
JE4GLE asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you! I solved it using a decorator to wrap it with the FlagProvider:

<script lang="ts">
    import type { Snippet } from 'svelte';
    import {FlagProvider} from "@unleash/proxy-client-svelte";

    let { children }: { children: Snippet } = $props();
</script>

<FlagProvider>
    {@render children()}
</FlagProvider>

and

const { Story } = defineMeta({
	title: 'Unleash Test',
        component: UnleashFlagTest,
        decorators: [() => FlagDecorator],
});

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JE4GLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants