Skip to content

Commit bb0302e

Browse files
committedSep 12, 2023
use asyncComponent func
1 parent 9887129 commit bb0302e

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed
 

‎jscomp/syntax/src/react_jsx_common.ml

+11-9
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ let add_async_attribute ~async (body : Parsetree.expression) =
7777
let is_async : Parsetree.attribute -> bool =
7878
fun ({txt}, _) -> txt = "async" || txt = "res.async"
7979

80-
let async_component expr =
81-
let open Ast_helper in
82-
Exp.apply
83-
(Exp.ident
84-
{
85-
loc = Location.none;
86-
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
87-
})
88-
[(Nolabel, expr)]
80+
let async_component ~async expr =
81+
if async then
82+
let open Ast_helper in
83+
Exp.apply
84+
(Exp.ident
85+
{
86+
loc = Location.none;
87+
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
88+
})
89+
[(Nolabel, expr)]
90+
else expr

‎jscomp/syntax/src/reactjs_jsx_v4.ml

+1-9
Original file line numberDiff line numberDiff line change
@@ -970,15 +970,7 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
970970
else fullExpression
971971
in
972972
let fullExpression =
973-
if isAsync then
974-
Exp.apply
975-
(Exp.ident
976-
{
977-
loc = Location.none;
978-
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
979-
})
980-
[(Nolabel, fullExpression)]
981-
else fullExpression
973+
React_jsx_common.async_component ~async:isAsync fullExpression
982974
in
983975
let fullExpression =
984976
match fullModuleName with

0 commit comments

Comments
 (0)