Using useReducer for form data
See original GitHub issueHave we discussed using useReducer
instead of useState
with an object for this? For this specific form it’s OK, but if we had more fields maybe useReducer
hook would make it more readable, since we’re just implementing our own reducer later in the handleChange
?
_Originally posted by @Zeko369 in https://github.com/freeCodeCamp/chapter/pull/140_
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
useReducer Form Example - Medium
This is a quick and dirty example of how useReducer is a great way for controlling complex state through the example of form...
Read more >Form Refactoring with useReducer React Hook (mini guide)
In this article, you are going to see a practical approach on how you can implement useReducer, and it also introduces the idea...
Read more >Using useContext and useReducer to Manage a Form's State
So far, we have created the initial state, created the Reducer, and attached the event handler to our inputs. Now let's provide the...
Read more >How to Build a Form in React with useReducer
First let's make a functional component in React to hold our form. import React, {useReducer} from "react"; const form = () => {...
Read more >Reactjs form validation with useReducer hook
useReducer hook can be used to handle complex state management scenarios. Using regular state management becomes cumbersome when part of the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wouldn’t it better to just use Formik? No need to reinvent the wheel
We had a vote during our Nov 15 conference call, and there was a consensus that we should try React-hook-form first and if we don’t like it, we can switch to Formik.