Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1847

Typing a useState

$
0
0

Hello, I am having some minor problems with a small thing.

On my playground below I make the compiler understand what I want to do with the following line

      | Loaded(asd: user) =>

but I would prefer if I could add a type already when I create the state

    let (user, setUser) = React.useState(_ => Loading)

Is it possible to add something to “Loading” there so that it knows that eventually it will be a user? It’s a small thing but the compiler somehow thinks I am passing a formstate even though the fullName is different from fullname and that it is a loadable type which formstate never is.

Playground to where you can see my code. Thanks in advance.


Viewing all articles
Browse latest Browse all 1847

Trending Articles