Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript error when using a function as defaultValue #6

Closed
digitaljohn opened this issue Mar 2, 2021 · 0 comments · Fixed by #5
Closed

Typescript error when using a function as defaultValue #6

digitaljohn opened this issue Mar 2, 2021 · 0 comments · Fixed by #5
Assignees
Labels
bug Something isn't working

Comments

@digitaljohn
Copy link
Contributor

It is not type-safe to set a value after using a function as the defaultValue.

const [token, setToken] = useLocalState("token", () => "computed value");

// This line would raise a typescript error as `string` is not the same type as `() => S`;
setToken("ABC123");

Which version of use-local-state are you using?

0.0.3

What version of React are you using use-local-state within?

16.8.0

What build/platform are you using?

Package test harness

What did you expect to happen?

Ability to set the value after using a computed function as the defaultValue.

What actually happened (e.g. what warnings or errors did you get)?

Typescript returns a warning that the new value does not match a function signature.

@digitaljohn digitaljohn added the bug Something isn't working label Mar 2, 2021
@digitaljohn digitaljohn self-assigned this Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant