reasonreason-react

This expression has type ... but an expression was expected of type


I am using bs-material-ui-icon binding, but I am given type error when try to use it component.

module Cell = {
  type status =
    | Empty
    | Tick
    | Cross;
  /* let icon =  React.createElement(MaterialUIIcons.AccessAlarm); */

  [@react.component]
  let make = _children => {
    <div> <MaterialUIIcons.AccessAlarm /> </div>; /** <MaterialUIIcons.AccessAlarm /> erorr **/
  };
};

Here is the error message it gave:

This expression has type
         'a =>
         ReasonReact.component(ReasonReact.stateless,
                                ReasonReact.noRetainedProps,
                                ReasonReact.actionless)
       but an expression was expected of type
         React.component('a) = 'a => React.element
       Type
         ReasonReact.component(ReasonReact.stateless,
                                ReasonReact.noRetainedProps,
                                ReasonReact.actionless)
           =
           ReasonReact.componentSpec(ReasonReact.stateless,
                                      ReasonReact.stateless,
                                      ReasonReact.noRetainedProps,
                                      ReasonReact.noRetainedProps,
                                      ReasonReact.actionless)
       is not compatible with type React.element 

I am using react-jsx 3 (if this matter)


Solution

  • Like @glennsl said, this is because you're missing JSXv2 and JSXv3. There is a new branch that supports JSXv3 which you can find here https://github.com/jsiebern/bs-material-ui/tree/hooks . It was published on npm in hooks tag.