-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Example for useReducer with types. #118
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
Conversation
Hey, sorry for delay got a really tough week, I'll get to it tomorrow. Cheers! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks quite good! Just need to make a couple of fixes following the comments and we are good to go. Thanks!
playground/package.json
Outdated
@@ -25,7 +25,7 @@ | |||
"dependencies": { | |||
"axios": "0.18.0", | |||
"cuid": "2.1.1", | |||
"react": "16.4.0", | |||
"react": "^16.8.0-alpha.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct all the added packages to use locked version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piotrwitek Sorry, I can't understand that what I should. How do I correct it to use the locked version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ^
prefix, everywhere you added them
playground/src/hooks/use-reducer.tsx
Outdated
} | ||
|
||
interface Action { | ||
type: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be an union, right now it's not type-safe
please declare:
type Action =
| { type: 'reset' }
| { type: 'increment' }
...
@piotrwitek I fixed the PR according to your review! please confirm:pray: |
Yeah, that looks great! Thanks for contribution. |
resolve #102
Caution
I installed
[email protected]
and@types/[email protected]
( and dependencies ) to use React Hooks.