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

Consider using a reducer #13

Open
oliverjam opened this issue May 31, 2019 · 0 comments
Open

Consider using a reducer #13

oliverjam opened this issue May 31, 2019 · 0 comments

Comments

@oliverjam
Copy link

const [type, setType] = React.useState(1);
const [allPokemon, setAllPokemon] = React.useState(null);
const [team, setTeam] = React.useState([]);
const [currentPokemon, setCurrentPokemon] = React.useState(null);
const [startDate, setStartDate] = React.useState(null);
const [countdown, setCountdown] = React.useState(time);
const [active, setActive] = React.useState(false);

We didn't cover this this week as it's a bit more advanced, but if you've got lots of state like this it can be a good idea to use React.useReducer() to group all your updates together.

You can read more about it in the docs

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

No branches or pull requests

1 participant