Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fix runtime type check for Object in untagged variants when one variant case is `null`. https://github.com/rescript-lang/rescript/pull/7303
- Fix files that were being truncated when sent to the CDN over FTP. https://github.com/rescript-lang/rescript/pull/7306
- Fix better editor completion for applications. https://github.com/rescript-lang/rescript/pull/7291
- Fix @react.componentWithProps no longer works with @directive("'use memo'"). https://github.com/rescript-lang/rescript/pull/7300

#### :house: Internal

Expand Down
7 changes: 7 additions & 0 deletions compiler/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =

let wrapper_expr =
Exp.fun_ ~arity:None Nolabel None props_pattern
~attrs:binding.pvb_expr.pexp_attributes
(Jsx_common.async_component ~async:is_async
(Exp.apply
(Exp.ident
Expand Down Expand Up @@ -1282,6 +1283,12 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
{
binding with
pvb_attributes = binding.pvb_attributes |> List.filter other_attrs_pure;
pvb_expr =
{
binding.pvb_expr with
(* moved to wrapper_expr *)
pexp_attributes = [];
};
},
new_binding )
else (None, binding, None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,15 @@ module V4A6 = {
\"SharedPropsWithProps$V4A6"
}
}

module V4A7 = {
type props = {count: int}

let make = props => {
React.int(props.count)
}
let make = {
let \"SharedPropsWithProps$V4A7" = @directive("'use memo'") props => make(props)
\"SharedPropsWithProps$V4A7"
}
}
10 changes: 10 additions & 0 deletions tests/syntax_tests/data/ppx/react/sharedPropsWithProps.res
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ module V4A6 = {
}
}
}

module V4A7 = {
type props = {count: int}

@react.componentWithProps
let make = @directive("'use memo'")
props => {
React.int(props.count)
}
}
10 changes: 10 additions & 0 deletions tests/tests/src/alias_default_value_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ let C7 = {
make: Alias_default_value_test$C7
};

function Alias_default_value_test$C8(props) {
'use memo';
return props.count;
}

let C8 = {
make: Alias_default_value_test$C8
};

export {
C0,
C1,
Expand All @@ -90,5 +99,6 @@ export {
C4,
C6,
C7,
C8,
}
/* No side effect */
11 changes: 11 additions & 0 deletions tests/tests/src/alias_default_value_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ module C7 = {
React.string(`Hello ${name}, you clicked me ` ++ times)
}
}

module C8 = {
type props = {count: int}

@react.componentWithProps
let make =
@directive("'use memo'")
props => {
React.int(props.count)
}
}