Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit c052cb9

Browse files
committed
fix the example of shared props for v4 spec
1 parent 02a3af8 commit c052cb9

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

cli/JSXV4.md

+15-18
Original file line numberDiff line numberDiff line change
@@ -379,30 +379,27 @@ let p: A.props<_> = {x: "x", y: "y"}
379379
V4 introduces support to set a props type from the outside. It allows sharing of the props type between components.
380380

381381
```rescript
382-
type sharedProps<'a> = {x: 'a, y: string}
382+
type sp = {x: string, y: string}
383+
type sp1<'a> = {x: 'a, y: string}
384+
type sp2<'a, 'b> = {x: 'a, y: 'b}
383385
384-
module A = {
385-
@react.component(:sharedProps<'a>)
386-
let make = (~x, ~y) => React.string(x ++ y)
386+
module C1 = {
387+
@react.component(:sp)
388+
let make = (~x, ~y) => body
387389
}
388390
389-
module B = {
390-
@react.component(:sharedProps<'a>)
391-
let make = (~x, ~y) => React.string(x ++ y)
391+
module C2 = {
392+
@react.component(:sp1<'a>)
393+
let make = (~x, ~y) => body
392394
}
393395
394-
// is transformed to
395-
module A = {
396-
type props<'a> = sharedProps<'a>
397-
398-
let make = ({x, y, _}: props<'a>) => React.string(x ++ y)
399-
...
396+
module C3 = {
397+
@react.component(:sp2<'a, 'b>)
398+
let make = (~x, ~y) => body
400399
}
401400
402-
module B = {
403-
type props<'a> = sharedProps<'a>
404-
405-
let make = ({x, y, _}: props<'a>) => React.string(x ++ y)
406-
...
401+
module C4 = {
402+
@react.component(:sp)
403+
let make = (~x:int, ~y) => body // type annotation is ignored by type sp1
407404
}
408405
```

0 commit comments

Comments
 (0)