Skip to content

Commit 9b77ccb

Browse files
committed
Update JSXV4 docs.
1 parent 1e23493 commit 9b77ccb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/JSXV4.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ is transformed to
272272
```rescript
273273
type props<'x, 'y, 'z> = {x: 'x, y?: 'y, z?: 'z}
274274
275-
({x, ?y, ?z}: props<_, _, _>) => {
275+
({x, ?y, ?z}: props<_, _, _>): Jsx.element => {
276276
let y = switch y {
277277
| None => 3 + x
278278
| Some(y) => y
@@ -281,7 +281,9 @@ type props<'x, 'y, 'z> = {x: 'x, y?: 'y, z?: 'z}
281281
}
282282
```
283283

284-
> Note: this implicit definition of type `props` means that there cannot be other type definitions of `props` in the same scope, or it will be a compiler error about multiple definitions of the type name.
284+
> Note:
285+
> - This implicit definition of type `props` means that there cannot be other type definitions of `props` in the same scope, or it will be a compiler error about multiple definitions of the type name.
286+
> - JSX V4 automatically adds a `Jsx.element` return constraint to all component functions. This ensures that components always return valid JSX elements and provides better type safety. If a component returns a non-JSX value, you'll get a helpful error message suggesting how to convert it (e.g., use `React.int` for integers, `React.string` for strings, etc.).
285287
286288
### Transformation for Component Application
287289

0 commit comments

Comments
 (0)