bfanger / svelte-preprocess-react

Seamlessly use React components inside a Svelte app
MIT License
126 stars 6 forks source link

React context example/docs? #35

Closed gigamesh closed 7 months ago

gigamesh commented 7 months ago

I'm trying to use a third-party authentication SDK but I'm unsure how to implement svelte-preprocess-react to use it in my svelte app. Are there any examples or documentation somewhere?

bfanger commented 7 months ago

The react-router example +layout.svelte & +page.svelte is an example of using React context.

To read the context you can use the hooks

<script lang="ts">
import { useUser }  from "third-party-auth"

const user = hooks(() => useUser())

$: console.log($user)
</script>
gigamesh commented 7 months ago

awesome thank you!