Skip to content

Fix JSX V4 build error when component props have the default value with same name #6377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add test
  • Loading branch information
mununki committed Aug 29, 2023
commit d8db53114f2c9a9439e49586d145ce21c5444a16
13 changes: 13 additions & 0 deletions jscomp/syntax/tests/ppx/react/defaultValueProp.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ module C1 = {
@react.component
let make = (~a=2, ~b) => React.int(a + b)
}

module C2 = {
let a = "foo"
@react.component
let make = (~a=a) => React.string(a)
}

module C3 = {
@react.component
let make = (~disabled as everythingDisabled: bool=false) => {
React.string(everythingDisabled ? "true" : "false")
}
}
39 changes: 39 additions & 0 deletions jscomp/syntax/tests/ppx/react/expected/defaultValueProp.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,42 @@ module C1 = {
\"DefaultValueProp$C1"
}
}

module C2 = {
let a = "foo"
type props<'a> = {a?: 'a}

let make = ({?a, _}: props<_>) => {
let a = switch a {
| Some(a) => a
| None => a
}

React.string(a)
}
let make = {
let \"DefaultValueProp$C2" = (props: props<_>) => make(props)

\"DefaultValueProp$C2"
}
}

module C3 = {
type props<'disabled> = {disabled?: 'disabled}

let make = ({disabled: ?everythingDisabled, _}: props<bool>) => {
let disabled = switch disabled {
| Some(disabled) => disabled
| None => false
}

{
React.string(everythingDisabled ? "true" : "false")
}
}
let make = {
let \"DefaultValueProp$C3" = (props: props<_>) => make(props)

\"DefaultValueProp$C3"
}
}