File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1840,9 +1840,10 @@ let rec is_nonexpansive exp =
18401840 List. for_all (fun vb -> is_nonexpansive vb.vb_expr) pat_exp_list
18411841 && is_nonexpansive body
18421842 | Texp_function _ -> true
1843- (* `%component_identity` is a typed no-op coercion. Treating it like an ordinary
1844- function call makes values such as `React.component(fn)` expansive, which
1845- prevents generalization of polymorphic props:
1843+ (* `%component_identity` is a typed no-op coercion that lets generated
1844+ component wrappers keep the same generalization behavior as their
1845+ underlying function values. This preserves polymorphic props for
1846+ components such as:
18461847
18471848 @react.component
18481849 let make = (~x) =>
@@ -1853,9 +1854,9 @@ let rec is_nonexpansive exp =
18531854 }
18541855
18551856 The JSX transform emits a function value and then coerces it through
1856- `React.component`, whose implementation is `%component_identity`. Since no runtime
1857- computation happens beyond evaluating the argument, the application is
1858- non-expansive exactly when all supplied arguments are non-expansive. *)
1857+ `React.component`, whose implementation is `%component_identity`. Since no
1858+ runtime computation happens beyond evaluating the argument, the application
1859+ is non-expansive exactly when all supplied arguments are non-expansive. *)
18591860 | Texp_apply {funct = {exp_desc}; args; _} when is_component_identity exp_desc
18601861 ->
18611862 List. for_all is_nonexpansive_opt (List. map snd args)
You can’t perform that action at this time.
0 commit comments