@@ -36,6 +36,8 @@ let constantString ~loc str =
36
36
(* {} empty record *)
37
37
let emptyRecord ~loc = Exp. record ~loc [] None
38
38
39
+ let unitExpr ~loc = Exp. construct ~loc (Location. mkloc (Lident " ()" ) loc) None
40
+
39
41
let safeTypeFromValue valueStr =
40
42
let valueStr = getLabel valueStr in
41
43
if valueStr = " " || (valueStr.[0 ] [@ doesNotRaise]) <> '_' then valueStr
@@ -385,21 +387,23 @@ let transformUppercaseCall3 ~config modulePath mapper jsxExprLoc callExprLoc
385
387
match config.mode with
386
388
(* The new jsx transform *)
387
389
| "automatic" ->
388
- let jsxExpr, key =
390
+ let jsxExpr, keyAndUnit =
389
391
match (! childrenArg, keyProp) with
390
392
| None , key :: _ ->
391
- ( Exp. ident {loc = Location. none; txt = Ldot (Lident " React" , " jsx" )},
392
- [key] )
393
+ ( Exp. ident
394
+ {loc = Location. none; txt = Ldot (Lident " React" , " jsxKeyed" )},
395
+ [key; (nolabel, unitExpr ~loc: Location. none)] )
393
396
| None , [] ->
394
397
(Exp. ident {loc = Location. none; txt = Ldot (Lident " React" , " jsx" )}, [] )
395
398
| Some _ , key :: _ ->
396
- ( Exp. ident {loc = Location. none; txt = Ldot (Lident " React" , " jsxs" )},
397
- [key] )
399
+ ( Exp. ident
400
+ {loc = Location. none; txt = Ldot (Lident " React" , " jsxsKeyed" )},
401
+ [key; (nolabel, unitExpr ~loc: Location. none)] )
398
402
| Some _ , [] ->
399
403
( Exp. ident {loc = Location. none; txt = Ldot (Lident " React" , " jsxs" )},
400
404
[] )
401
405
in
402
- Exp. apply ~attrs jsxExpr (key @ [(nolabel, makeID); (nolabel, props)])
406
+ Exp. apply ~attrs jsxExpr ([(nolabel, makeID); (nolabel, props)] @ keyAndUnit )
403
407
| _ -> (
404
408
match (! childrenArg, keyProp) with
405
409
| None , key :: _ ->
@@ -488,23 +492,25 @@ let transformLowercaseCall3 ~config mapper jsxExprLoc callExprLoc attrs
488
492
let keyProp =
489
493
args |> List. filter (fun (arg_label , _ ) -> " key" = getLabel arg_label)
490
494
in
491
- let jsxExpr, key =
495
+ let jsxExpr, keyAndUnit =
492
496
match (! childrenArg, keyProp) with
493
497
| None , key :: _ ->
494
- ( Exp. ident {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsx" )},
495
- [key] )
498
+ ( Exp. ident
499
+ {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsxKeyed" )},
500
+ [key; (nolabel, unitExpr ~loc: Location. none)] )
496
501
| None , [] ->
497
502
( Exp. ident {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsx" )},
498
503
[] )
499
504
| Some _ , key :: _ ->
500
- ( Exp. ident {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsxs" )},
501
- [key] )
505
+ ( Exp. ident
506
+ {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsxsKeyed" )},
507
+ [key; (nolabel, unitExpr ~loc: Location. none)] )
502
508
| Some _ , [] ->
503
509
( Exp. ident {loc = Location. none; txt = Ldot (Lident " ReactDOM" , " jsxs" )},
504
510
[] )
505
511
in
506
512
Exp. apply ~attrs jsxExpr
507
- (key @ [(nolabel, componentNameExpr); (nolabel, props)])
513
+ ([(nolabel, componentNameExpr); (nolabel, props)] @ keyAndUnit )
508
514
| _ ->
509
515
let children, nonChildrenProps =
510
516
extractChildren ~loc: jsxExprLoc callArguments
0 commit comments