Skip to content

Add error using @react.componentWithProps with external - #7217

Merged
cknitt merged 5 commits into
masterfrom
error-react-component-with-props-external
Dec 30, 2024
Merged

cknitt merged 5 commits into
masterfrom
error-react-component-with-props-external

Conversation

@mununki

@mununki mununki commented Dec 24, 2024

Copy link
Copy Markdown
Member

Resolves #7215

@mununki
mununki requested a review from cknitt December 24, 2024 08:53
Comment thread compiler/syntax/src/jsx_v4.ml Outdated
| _, [_] ->
Jsx_common.raise_error ~loc:pstr_loc
"Components cannot be defined as externals when using \
@react.componentWithProps. Please use @react.component instead."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if the user intended to define a React component as a function of a props record, we should rather tell him to use the type React.component<props> in his external definition instead.

So maybe the message should be something like

Components cannot be defined as externals when using @react.componentWithProps.

If you intended to define an external for a React component using a props type,
use the type React.component<props> instead.
Alternatively, use @react.component for an external definition with labeled arguments.

@mununki
mununki requested a review from cknitt December 30, 2024 04:12
@cknitt

cknitt commented Dec 30, 2024

Copy link
Copy Markdown
Member

Oh, CI failed, you still need to update the error message in the tests.

@mununki

mununki commented Dec 30, 2024

Copy link
Copy Markdown
Member Author

Oh, CI failed, you still need to update the error message in the tests.

Oh, I forgot it. Done 4e2d358

@cknitt
cknitt merged commit 32fa620 into master Dec 30, 2024
@cknitt
cknitt deleted the error-react-component-with-props-external branch December 30, 2024 09:11
aspeddro pushed a commit to aspeddro/rescript-compiler that referenced this pull request Oct 31, 2026
…-lang#7217)

* Add error using @react.componentWithProps with external

* wildcard pattern

* change log

* fix error message

* update error message

Signed-off-by: Pedro Castro <aspeddro@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add error for the use case @react.componentWithProps with external bindings

2 participants