Skip to content

Very misleading error message if you misuse [@react.component] #843

@Josef-Thorne-A

Description

@Josef-Thorne-A

If you put [@reason.component] in the wrong location it will give a very confusing and uninformative error. This took me a couple hours to track down properly:

Example of problematic code:

[@react.component]`
let (pageState,setPageState) = React.useState(_ => testState);

let make { ...}

For me at least in an error message in the associated dune file was given, nowhere near where the issue was -- nor obviously related to incorrect ppx directives:

7 |  (preprocess (pps melange.ppx reason-react-ppx)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fatal error: exception Invalid_argument("react.component calls cannot be destructured."

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions