Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj authored Aug 16, 2024
1 parent 1e4d1ac commit 6266406
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm i unplugin-vue-jsx-vapor
```

> [!CAUTION]
> The destructuring of props in a functional component will cause loss of reactivity.
> The destructuring of props in a functional component will cause loss of reactivity.
```tsx
function Comp({ foo }) {
Expand All @@ -24,9 +24,9 @@ const foo = ref('foo')
export default <Comp foo={foo.value} />
```

#### Solutions
#### Two Solutions

1. Pass a ref variable as prop:
1. Pass a ref variable as prop:

```tsx
function Comp({ foo }) {
Expand All @@ -37,7 +37,7 @@ const foo = ref('foo')
export default <Comp foo={foo} />
```

2. Turn on the restructure option to restructure props.
2. Turn on the restructure option to restructure props.

```ts
// vite.config.ts
Expand All @@ -58,6 +58,9 @@ function Comp({ foo }) {
function Comp(_ctx0) {
return <div>{_ctx0.foo}</div>
}

const foo = ref('foo')
export default <Comp foo={foo.value} />
```

<details>
Expand Down

0 comments on commit 6266406

Please sign in to comment.