freeCodeCamp / chapter

A self-hosted event management tool for nonprofits
BSD 3-Clause "New" or "Revised" License
1.92k stars 360 forks source link

Using useReducer for form data #163

Closed Zeko369 closed 4 years ago

Zeko369 commented 4 years ago

Have 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

papigers commented 4 years ago

Wouldn't it better to just use Formik? No need to reinvent the wheel

Zeko369 commented 4 years ago

I've heard that their hooks integration isn't the best, maybe some other form library that works better with hooks?

Zeko369 commented 4 years ago

Or just plain useState/useReducer

papigers commented 4 years ago

@Zeko369 I never used Formik in the React Hooks era, so I can't say much about their hooks integration. There's also React Hook Form which is relatively new and claims to be a far better option, but I don't have any personal experience with it.

Zeko369 commented 4 years ago

That seems quite nice, what do others think? @timmyichen @joelrozen @vaibhavsingh97 @nik-john

timmyichen commented 4 years ago

react-hook-form seems nice and small. haven't used it before but i'm down to try.

Sonicrida commented 4 years ago

My thought is to go with Formik since it's battle tested + what most people may be familiar with. It also has hooks now if those are needed.

allella commented 4 years ago

@timmyichen @joelrozen @vaibhavsingh97 @nik-john what say ye?

joelrozen commented 4 years ago

We have used formik internally on a lot of projects and it's great. I actually took part of my logic for this from our internal stuff and just rewrote to use without formik

QuincyLarson commented 4 years ago

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.