Skip to content

Commit 0e57075

Browse files
committed
doc: Updated docs for v3
1 parent 4835fdf commit 0e57075

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[![svelte-preprocess-react](./static/svelte-preprocess-react.svg)](https://www.npmjs.com/package/svelte-preprocess-react)
22

3-
# Svelte Preprocess React
3+
See [v2.x Readme](https://github.com/bfanger/svelte-preprocess-react/blob/2.1.4/README.md) for the stable version.
4+
5+
# Svelte Preprocess React - 3.0-beta
46

57
Seamlessly use React components inside a Svelte app
68

@@ -28,8 +30,9 @@ Use libraries from the React's ecosystem, react-youtube for example:
2830
```svelte
2931
<script>
3032
import YouTube from "react-youtube";
33+
import { sveltify } from "svelte-preprocess-react";
3134
32-
const react = sveltify({ YouTube }); // Optional step, but adds type-safety
35+
const react = sveltify({ YouTube });
3336
</script>
3437
3538
<react.YouTube videoId="AdNJ3fydeao" />
@@ -46,10 +49,7 @@ The snippet above would be generate:
4649
import { sveltify } from "svelte-preprocess-react";
4750
import YouTube from "react-youtube";
4851
49-
const react = sveltify(
50-
{ YouTube },
51-
{ createPortal, ReactDOM, renderToString },
52-
);
52+
const react = sveltify({ YouTube });
5353
</script>
5454
5555
<react.YouTube videoId="AdNJ3fydeao" />
@@ -58,7 +58,7 @@ The snippet above would be generate:
5858
## Setup / Installation
5959

6060
```sh
61-
npm install --save-dev svelte-preprocess-react react react-dom
61+
npm install --save-dev svelte-preprocess-react@next react react-dom
6262
```
6363

6464
Add `preprocessReact` to your svelte.config.js:
@@ -69,6 +69,9 @@ import preprocessReact from "svelte-preprocess-react/preprocessReact";
6969

7070
export default {
7171
preprocess: preprocessReact(),
72+
compilerOptions: {
73+
experimental: { async: true }, // v3.0 relies on async svelte components
74+
},
7275
};
7376
```
7477

@@ -81,6 +84,9 @@ import preprocessReact from "svelte-preprocess-react/preprocessReact";
8184

8285
export default {
8386
preprocess: [vitePreprocess(), preprocessReact()],
87+
compilerOptions: {
88+
experimental: { async: true },
89+
},
8490
};
8591
```
8692

docs/hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The `hooks()` function uses Svelte lifecycle functions, so you can only call the
1010
<script lang="ts">
1111
import { hooks } from "svelte-preprocess-react";
1212
13-
const [count, setCount] = $derived.by(hooks(() => useState(0)));
13+
const [count, setCount] = $derived.by(await hooks(() => useState(0)));
1414
</script>
1515
1616
<h2>Count: {count}</h2>
@@ -21,7 +21,7 @@ hooks() returns a function, when that function retrieves the reactive state, by
2121

2222
```ts
2323
const actions = $derived.by(
24-
hooks(() => {
24+
await hooks(() => {
2525
const multiplier = useContext(MultiplierContext);
2626
const [count, setCount] = useState(0);
2727
return {

0 commit comments

Comments
 (0)