Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions src/content/learn/react-compiler/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,32 @@ module.exports = {

### Vite {/*vite*/}

If you use Vite, you can add the plugin to vite-plugin-react:
If you use Vite with version 6.0.0 or later of `@vitejs/plugin-react`, you can use the `reactCompilerPreset`:

```js {3,9}
<TerminalBlock>
npm install -D @rolldown/plugin-babel
</TerminalBlock>

```js {3-4,9-11}
// vite.config.js
import { defineConfig } from 'vite';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
import babel from '@rolldown/plugin-babel';

export default defineConfig({
plugins: [
react(),
babel({
presets: [reactCompilerPreset()]
}),
],
});
```

<Note>
In `@vitejs/plugin-react@6.0.0`, the inline Babel option was removed. If you're using an older version, you can use:

```js
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
Expand All @@ -81,26 +104,21 @@ export default defineConfig({
],
});
```
</Note>

Alternatively, if you prefer a separate Babel plugin for Vite:

<TerminalBlock>
npm install -D vite-plugin-babel
</TerminalBlock>
Alternatively, you can use the Babel plugin directly with `@rolldown/plugin-babel`:

```js {2,11}
```js {3,9}
// vite.config.js
import babel from 'vite-plugin-babel';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import babel from '@rolldown/plugin-babel';

export default defineConfig({
plugins: [
react(),
babel({
babelConfig: {
plugins: ['babel-plugin-react-compiler'],
},
plugins: ['babel-plugin-react-compiler'],
}),
],
});
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/react/useOptimistic.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function handleClick() {
#### How optimistic state works {/*how-optimistic-state-works*/}
`useOptimistic` lets you show a temporary value while a Action is in progress:
`useOptimistic` lets you show a temporary value while an Action is in progress:
```js
const [value, setValue] = useState('a');
Expand Down
Loading