Problems with rei with React component


#1

I have this code

open ReactNative;
open CustomStyles;

type buttonState =
  | NoClicked
  | Clicked;

type state = {
  label: string,
  count: int,
};

[@react.component]
let make = () => {
  let (state, dispatch) =
    React.useReducer(
      ({count}, action) =>
        switch (action) {
        | NoClicked => {label: "NO Clicks", count: 0}
        | Clicked => {
            label: "Clicks " ++ Belt.Int.toString(count + 1),
            count: count + 1,
          }
        },
      {label: "NO Clicks", count: 0},
    );
  <View style={styles##sectionContainer}>
    <Text style={styles##sectionTitle}>
      "Step One In Component"->React.string
    </Text>
    <Text style={styles##sectionDescription}>
      "Edit "->React.string
      <Text style={styles##highlight}> "src/App.re"->React.string </Text>
      " to change this screen and then come back to see your edits."
      ->React.string
    </Text>
    <Button title={state.label} onPress={_evt => {dispatch(Clicked)}} />
  </View>;
};

And I generate its interface file

let make: {.} => React.element;

for the make function but I got this error:

The implementation /home/mrkaspa/code/re/renative_demo/src/CounterReducer.re
     does not match the interface src/CounterReducer.cmi:
     Values do not match:
       let make: {. } => React.element
     is not included in
       let make: {. } => React.element
     File "/home/mrkaspa/code/re/renative_demo/src/CounterReducer.rei", line 1, characters 0-30:
       Expected declaration

What can be the problem


#2

For the interface file, use [@react.component] to generate the proper type:

// CounterReducer.rei

[@react.component]
let make: unit => React.element;

#3

Thank you it worked, the error message should be clearer though