Introduction reason react example doesn't work



I am familiar with OCaml but quite new in the Reason environment.

I had some trouble with reason react. I can’t compile the first reason react example :

I always have this cryptic type error :
/Users/nicolasassouad/perso/concern/src/ 10:4-11

8 │ */
9 │ ReactDOMRe.renderToElementWithId(
10 │ <Greeting name=“John”/>,
11 │ "greeting"
12 │ );

This function has type {. “name”: string} => ReasonReact.reactElement
It only accepts 1 argument; here, it’s called with more.

Can someone help me out ?



I think I’ve reproduced your error. Are you writing new-style JSX 3 components, but have JSX 2 enabled? Try putting this at the top of the file defining the component:
[@bs.config {jsx: 3}];

Take a look here for details


Also, for future debugging people:

We had the same issue, even though we added the decorator at the top of the file, but it turned out we had forgotten the semicolon after the decorator.

What we had:

[@bs.config {jsx: 3}]

blah blah code

But what we needed:

[@bs.config {jsx: 3}];

blah blah code

Notice that little semicolon.