I have this module that is compiling. When I use the module, like so,
ReactDOMRe.renderToElementWithId(
<Authenticator.WithAuthenticator>
<ReasonApollo.Provider client=Client.instance>
<App />
/* <App /> */
</ReasonApollo.Provider>
</Authenticator.WithAuthenticator>,
"root",)
it is producing the following error.
17 │ Js.log(token);
18 │ ReactDOMRe.renderToElementWithId(
19 │ <Authenticator.WithAuthenticator>
20 │ <ReasonApollo.Provider client=Client.instance>
21 │ <App />
This call is missing an argument of type
(~authState: option(Authenticator.authData)) => React.element
How would I resolve this error?
The full module is:
[@bs.module "aws-amplify-react"] [@react.component]
external make: ('a) => React.element = "Authenticator";
type authData = string;
let getToken: authData => string = [%raw
{|
function(a){
return a.currentAuthenticatedUser.idToken.jwtToken;
}
|}
];
module Authenticator = {
type authState = string;
type onStateChange = (authState, authData) => unit;
[@react.component]
let make = (~onStateChange, ~children) => {
children
};
};
module WithAuthenticator = {
type state = {authData: option(authData)};
type action =
| Update(authData);
let initialState = {authData: None};
let reducer = (state, action) =>
switch (action) {
| Update(authData) => {authData: Some(authData)}
};
[@react.component]
let make = children => {
let (state, dispatch) = React.useReducer(reducer, initialState);
<Authenticator onStateChange={authData => dispatch(Update(authData))}>
{children(~authState=state.authData)}
</Authenticator>;
};
};
Thank you.