DEV Community

Discussion on: ReasonReact context explained in action

Collapse
 
margaretkrutikova profile image
Margarita Krutikova

Sorry, could you clarify what you mean by "you didn't use the hook in the app"? I did use it here.

That's actually a very good question. Usually you need to pass unit () in the end if you have optional labeled arguments. If you don't enforce this, the compiler won't know whether you want to partially apply arguments to your function (=curried function, and maybe pass that optional argument later?) or you actually want to omit that argument and call the function right away.

I assume, since all components can optionally receive key as prop, you have to explicitly pass that unit to make sure it is going to be called and not partially applied. You can see here in the docs that reason component will generate makeProps like this:

[@bs.obj]
external makeProps: (~name: 'name, ~key: string=?, unit) => {. "name": 'name} = "";

So I think it will always have that optional argument key. I hope this makes sense!

Collapse
 
idkjs profile image
Alain

Indeed you did. In your post you had it assigned to a function and looked for that in the code. You ended up using it directly in form onSubmit. github.com/MargaretKrutikova/pract...

Nice.

Optional key. Of course. I was wondering which of these props is optional. Tack, Madame. You are appreciated!