Skip to content

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

Merged
merged 7 commits into from
Jan 21, 2019

Conversation

sosukesuzuki
Copy link
Contributor

resolve #102

Caution

I installed [email protected] and @types/[email protected] ( and dependencies ) to use React Hooks.

@piotrwitek
Copy link
Owner

piotrwitek commented Jan 19, 2019

Hey, sorry for delay got a really tough week, I'll get to it tomorrow. Cheers!

Copy link
Owner

@piotrwitek piotrwitek left a 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!

@@ -25,7 +25,7 @@
"dependencies": {
"axios": "0.18.0",
"cuid": "2.1.1",
"react": "16.4.0",
"react": "^16.8.0-alpha.0",
Copy link
Owner

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

Copy link
Contributor Author

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?

Copy link
Owner

@piotrwitek piotrwitek Jan 21, 2019

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

}

interface Action {
type: string;
Copy link
Owner

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' }
  ...

@sosukesuzuki
Copy link
Contributor Author

@piotrwitek I fixed the PR according to your review! please confirm:pray:

@piotrwitek
Copy link
Owner

Yeah, that looks great! Thanks for contribution.

@piotrwitek piotrwitek merged commit 86902ac into piotrwitek:master Jan 21, 2019
@sosukesuzuki sosukesuzuki deleted the hooks-use-reducer branch January 21, 2019 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add useReducer hook with types example
2 participants