Skip to content

Commit 324ab31

Browse files
authored
Add mangling prop name in JSX v4 (#639)
1 parent 5a79453 commit 324ab31

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pages/docs/react/latest/migrate-react.mdx

+29
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,32 @@ let make = () => {
211211
</div>
212212
}
213213
```
214+
215+
### Mangling the prop name
216+
217+
The prop name was mangled automatically in v3, such as `_open` becomes `open` in the generated js code. This is no longer the case in v4 because the internal representation is changed to the record instead object. If you need to mangle the prop name, you can use the `@as` annotation.
218+
219+
Rewrite this:
220+
221+
```res
222+
module Comp = {
223+
@react.component
224+
let make = (~_open, ~_type) =>
225+
<Modal _open _type>
226+
<Description />
227+
</Modal>
228+
}
229+
```
230+
231+
To this:
232+
233+
```res
234+
module Comp = {
235+
@react.component
236+
let make =
237+
(@as("open") ~_open, @as("type") ~_type) =>
238+
<Modal _open _type>
239+
<Description />
240+
</Modal>
241+
}
242+
```

0 commit comments

Comments
 (0)