Skip to content

Commit a77f2f1

Browse files
committed
clean up the attribute after transformation
1 parent ac9c8ae commit a77f2f1

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

compiler/syntax/src/jsx_v4.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,13 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
11941194
else if Jsx_common.has_attr_on_binding Jsx_common.has_attr_with_props binding
11951195
then
11961196
let modified_binding = Jsx_common.remove_arity binding in
1197+
let modified_binding =
1198+
{
1199+
modified_binding with
1200+
pvb_attributes =
1201+
modified_binding.pvb_attributes |> List.filter other_attrs_pure;
1202+
}
1203+
in
11971204
let fn_name = get_fn_name modified_binding.pvb_pat in
11981205
let internal_fn_name = fn_name ^ "$Internal" in
11991206
let full_module_name =

tests/syntax_tests/data/ppx/react/expected/sharedPropsWithProps.res.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ let f = a => Js.Promise.resolve(a + a)
55
module V4C1 = {
66
type props = sharedProps
77
let make = props => React.string(props.x ++ props.y)
8-
@react.componentWithProps
98
let make = {
109
let \"SharedPropsWithProps$V4C1" = props => make(props)
1110
\"SharedPropsWithProps$V4C1"
@@ -15,7 +14,6 @@ module V4C1 = {
1514
module V4C2 = {
1615
type props = sharedProps
1716
let make = (props: props) => React.string(props.x ++ props.y)
18-
@react.componentWithProps
1917
let make = {
2018
let \"SharedPropsWithProps$V4C2" = (props: props) => make(props)
2119
\"SharedPropsWithProps$V4C2"
@@ -25,7 +23,6 @@ module V4C2 = {
2523
module V4C3 = {
2624
type props<'a> = sharedProps<'a>
2725
let make = ({x, y}: props<_>) => React.string(x ++ y)
28-
@react.componentWithProps
2926
let make = {
3027
let \"SharedPropsWithProps$V4C3" = (props: props<_>) => make(props)
3128
\"SharedPropsWithProps$V4C3"
@@ -35,7 +32,6 @@ module V4C3 = {
3532
module V4C4 = {
3633
type props<'a> = sharedProps<string, 'a>
3734
let make = ({x, y}: props<_>) => React.string(x ++ y)
38-
@react.componentWithProps
3935
let make = {
4036
let \"SharedPropsWithProps$V4C4" = (props: props<_>) => make(props)
4137
\"SharedPropsWithProps$V4C4"
@@ -48,7 +44,6 @@ module V4C5 = {
4844
let a = await f(a)
4945
ReactDOM.createDOMElementVariadic("div", [{React.int(a)}])
5046
}
51-
@react.componentWithProps
5247
let make = {
5348
let \"SharedPropsWithProps$V4C5" = (props: props<_>) =>
5449
JsxPPXReactSupport.asyncComponent(make(props))
@@ -64,7 +59,6 @@ module V4C6 = {
6459
| #off => React.string("off")
6560
}
6661
}
67-
@react.componentWithProps
6862
let make = {
6963
let \"SharedPropsWithProps$V4C6" = (props: props<_>) =>
7064
JsxPPXReactSupport.asyncComponent(make(props))
@@ -77,7 +71,6 @@ module V4C6 = {
7771
module V4A1 = {
7872
type props = sharedProps
7973
let make = props => React.string(props.x ++ props.y)
80-
@react.componentWithProps
8174
let make = {
8275
let \"SharedPropsWithProps$V4A1" = props => make(props)
8376
\"SharedPropsWithProps$V4A1"
@@ -87,7 +80,6 @@ module V4A1 = {
8780
module V4A2 = {
8881
type props = sharedProps
8982
let make = (props: props) => React.string(props.x ++ props.y)
90-
@react.componentWithProps
9183
let make = {
9284
let \"SharedPropsWithProps$V4A2" = (props: props) => make(props)
9385
\"SharedPropsWithProps$V4A2"
@@ -97,7 +89,6 @@ module V4A2 = {
9789
module V4A3 = {
9890
type props<'a> = sharedProps<'a>
9991
let make = ({x, y}: props<_>) => React.string(x ++ y)
100-
@react.componentWithProps
10192
let make = {
10293
let \"SharedPropsWithProps$V4A3" = (props: props<_>) => make(props)
10394
\"SharedPropsWithProps$V4A3"
@@ -107,7 +98,6 @@ module V4A3 = {
10798
module V4A4 = {
10899
type props<'a> = sharedProps<string, 'a>
109100
let make = ({x, y}: props<_>) => React.string(x ++ y)
110-
@react.componentWithProps
111101
let make = {
112102
let \"SharedPropsWithProps$V4A4" = (props: props<_>) => make(props)
113103
\"SharedPropsWithProps$V4A4"
@@ -120,7 +110,6 @@ module V4A5 = {
120110
let a = await f(a)
121111
ReactDOM.jsx("div", {children: ?ReactDOM.someElement({React.int(a)})})
122112
}
123-
@react.componentWithProps
124113
let make = {
125114
let \"SharedPropsWithProps$V4A5" = (props: props<_>) =>
126115
JsxPPXReactSupport.asyncComponent(make(props))
@@ -136,7 +125,6 @@ module V4A6 = {
136125
| #off => React.string("off")
137126
}
138127
}
139-
@react.componentWithProps
140128
let make = {
141129
let \"SharedPropsWithProps$V4A6" = (props: props<_>) =>
142130
JsxPPXReactSupport.asyncComponent(make(props))

0 commit comments

Comments
 (0)