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
46 changes: 36 additions & 10 deletions src/content/learn/react-compiler/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,36 @@ module.exports = {

### Vite {/*vite*/}

<<<<<<< HEAD
如果你使用 Vite,可以将插件添加到 vite-plugin-react 中:
=======
If you use Vite with version 6.0.0 or later of `@vitejs/plugin-react`, you can use the `reactCompilerPreset`:
>>>>>>> 47e64bf7ad81aab8bacfa791a37816ee869135eb

```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 +108,25 @@ export default defineConfig({
],
});
```
</Note>

<<<<<<< HEAD
或者,如果你更倾向于为 Vite 使用一个独立的 Babel 插件:
=======
Alternatively, you can use the Babel plugin directly with `@rolldown/plugin-babel`:
>>>>>>> 47e64bf7ad81aab8bacfa791a37816ee869135eb

<TerminalBlock>
npm install -D vite-plugin-babel
</TerminalBlock>

```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