Using Immer with Reducers and React Hooks

Using Immer with Reducers and React Hooks

Ben Awad

5 лет назад

26,640 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

sadmeowmeow
sadmeowmeow - 07.03.2023 13:17

Helpful

Ответить
max fox
max fox - 29.06.2022 09:20

Thx

Ответить
Ahmed Alaa
Ahmed Alaa - 29.03.2022 15:29

Thank you

Ответить
wintr li8
wintr li8 - 07.10.2021 11:12

I wonder why the name "unshift" was chosen by spec designers? Would've been really easier if they had given it some easier name.

Ответить
Tom Thanh
Tom Thanh - 01.09.2021 05:26

Thanks! This is so useful. I encountered this at work and you save me.

Ответить
Mehdi Raash
Mehdi Raash - 18.06.2021 01:20

A nice Game Changer.

Ответить
Bobby Gondola
Bobby Gondola - 30.07.2020 17:57

redux is way too much boiler plate. whoever created it was on crack

Ответить
Android480
Android480 - 03.07.2020 23:42

This might be outdated, but I'm using Immer for the first time and mutating the draft object NEVER causes a re-render for any of my functional components. I'm using useSelector. Why is this?

Ответить
Gabe O'Leary
Gabe O'Leary - 19.12.2019 00:32

What extension are you using to show the size of imported packages?

Ответить
約翰
約翰 - 30.09.2019 14:18

ty for sharing

Ответить
Creative Commons Videos
Creative Commons Videos - 26.08.2019 13:11

I have one question, redux has one hook called useSelector, so if i use that, can i stop using reselect, are both doing same ? do useSelector give the same performance ?

Ответить
Raushan Sharma
Raushan Sharma - 07.06.2019 18:58

This is what I was looking for, I had already done making my userReducer a lot mess. This will certainly make my reducer cleaner.

Ответить
Mark Robinson
Mark Robinson - 18.11.2018 12:43

Random question, but is there any reason why you can't make a copy of todos yourself and modify the copy then return the copy instead of pulling in a library for that? That way you can do what you want and you aren't modifying the state. For example:


const todosReducer = (todos, action) => {
const state = todos.slice();
switch (action.type) {
case "ADD_TODO":
state.unshift({ text: action.text, complete: false });
return state;
case "TOGGLE_COMPLETE":
state[action.i].complete = !state[action.i].complete;
return state;
case "RESET":
return [];
default:
return todos;
}
};




Cheers for the vids, enjoying them (learning react atm)

Ответить
Yaroslav (JLarky) Lapin
Yaroslav (JLarky) Lapin - 02.11.2018 07:42

Funny how no one noticed that you have bug handling RESET case with immer :)

Ответить
Andrés Montoya
Andrés Montoya - 01.11.2018 23:32

Great video! Thanks! Will you do more about immer then?

Ответить
Ganapati V.S
Ganapati V.S - 01.11.2018 19:33

Immer hooks are awesome!

Ответить
Ayden Prehot
Ayden Prehot - 01.11.2018 08:48

so glad you ended up trying it out Ben! love it!

Ответить
Vincent St. Louis
Vincent St. Louis - 01.11.2018 03:13

Bravo.

Ответить
Alexander MC
Alexander MC - 01.11.2018 00:07

Hey Ben, immer is a good library, but need to mention that it doesn't work in IE11 and there is no way to polyfill it since it's based on JS Proxy.

Ответить
natqe
natqe - 01.11.2018 00:06

Why not just clone the todos with lodash.cloneDeep function?

Ответить
Adam Aho
Adam Aho - 31.10.2018 23:40

Why not use Immutable? I use it in production all the time. Makes it much easier!

Ответить
ᚷᚨᛚᛗ
ᚷᚨᛚᛗ - 31.10.2018 22:03

This is exciting, thanks

Ответить
NoNamedTEHb
NoNamedTEHb - 31.10.2018 20:09

Hi. Does immer say something about calculation speed? Immutable also was good approach ...

Ответить
Techonsapevole
Techonsapevole - 31.10.2018 18:33

very clean approch

Ответить
George Mariona
George Mariona - 31.10.2018 18:13

Great video thanks👌

Ответить
Harshal Hirve
Harshal Hirve - 31.10.2018 17:19

Hey Ben, this is super useful. Will definitely try it in my next project. Thank you so much for publishing such latest videos. Your hardwork is much appreciated. :)😊

Ответить