A cure for React useState hell

preview_player
Показать описание

#react #javascript #js #webdev
Рекомендации по теме
Комментарии
Автор

As angular developer i amazed every time how inconvenient react is.

RezetRoy
Автор

I would happily pay for the react course . These are real usable features

satyak
Автор

If there’s ever an opportunity to use the useReducer hook, I typically use a better state management tool like RTK to handle it

bob_kazamakis
Автор

You can also use an object for the state and pass a function to setState to without going into a whole reducer pattern

jethrolarson
Автор

You can also create a custom hook for forms.

emiliorobertofabricianocon
Автор

So one of reasons why react moved from component api to hooks is modular tine states. Now it is called “useState hell”. Nice

vladislavstepanov
Автор

Dude you'r tips are awesome, keep going

mohammadsajjadjalalimanesh
Автор

it gets even better if you use ts-pattern in the reducer

sobrevivendo-no-front
Автор

Vue with it's reactive({ ... }) laughing

RiadDZz
Автор

Do you know the setState fn returned by useState hook accepts a function and you can apply your state update logic there? You'll also get the previous state as the fn argument.

But useReducer is cleaner, easy to understand and debug.

the_truth_seeker
Автор

The not really redux but pretty much redux hook( with context)

_jovian
Автор

Isnt Calendar valid start/end date and input max length covered by plain HTML 5 without any need of coding?!

janekschleicher
Автор

Awesome stuff, was curious about a better way to implement logic like this in complicated forms.

ShaanCoding
Автор

If you’re dealing with this many state variables, you really should just go with xstate. Because of the complex interactions between them and needing to establish what is success, and what is not beyond just setting a new value.

jsward
Автор

You should also take advantage of Immer for creating the state clones

davidnogueira
Автор

The problem I have with useReducer (or with this video, I don't know exactly), is that the word reducer seems really random to me. I don't know what it means in this context. Also it doesn't seem to match reducers as I have learned them in ngrx.

HorstKirkPageKian
Автор

Слава богу, что я пишу на Vue. Уже успел позабыть сколько пердолинга приносил мне React

gerda-morozova
Автор

Simplicity and readability Left the chat 😅

gimnathpriyadarshanaperera
Автор

Or you can use an object as the initial value of useState which should have all the states shown as properties. This object is called query object.

HabiburRahman-vjws
Автор

Just curious, why not using some sort of form library to handle validation like this?

mdway