Skip to content

Commit

Permalink
use asyncComponent func
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Sep 12, 2023
1 parent 9887129 commit bb0302e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
20 changes: 11 additions & 9 deletions jscomp/syntax/src/react_jsx_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ let add_async_attribute ~async (body : Parsetree.expression) =
let is_async : Parsetree.attribute -> bool =
fun ({txt}, _) -> txt = "async" || txt = "res.async"

let async_component expr =
let open Ast_helper in
Exp.apply
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
})
[(Nolabel, expr)]
let async_component ~async expr =
if async then
let open Ast_helper in
Exp.apply
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
})
[(Nolabel, expr)]
else expr
10 changes: 1 addition & 9 deletions jscomp/syntax/src/reactjs_jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -970,15 +970,7 @@ let mapBinding ~config ~emptyLoc ~pstr_loc ~fileName ~recFlag binding =
else fullExpression
in
let fullExpression =
if isAsync then
Exp.apply
(Exp.ident
{
loc = Location.none;
txt = Ldot (Lident "JsxPPXReactSupport", "asyncComponent");
})
[(Nolabel, fullExpression)]
else fullExpression
React_jsx_common.async_component ~async:isAsync fullExpression
in
let fullExpression =
match fullModuleName with
Expand Down

0 comments on commit bb0302e

Please sign in to comment.