One Cool Trick to Simplify Your Reducers
Автор: Eric Elliott
Загружено: 2020-06-04
Просмотров: 8593
Описание:
Redux is an amazing tool if you take the time to get to know it. One of the things about Redux that commonly trips people up is that reducers must be pure functions.
A pure function is a function which:
Given same arguments, always returns the same result, and
Has no side-effects (e.g., it won't mutate its input arguments).
The problem is that sometimes a reducer needs to make a complicated change to some input state, but you can't just mutate the state argument without causing bugs.
The solution is a handy tool called Immer. In this video, I'll introduce you to Immer and show you how to use it to reduce the complexity of your reducer code. With one or two small reducers, the difference is pretty subtle, but on a large project, it can significantly simplify your application code.
Blog post with source code: / one-cool-trick-to-simplify-reducer-functions
Immer on GitHub: https://github.com/immerjs/immer
Resources for JavaScript developers:
DevAnywhere - Live, remote 1:1 mentorship subscription: https://DevAnywhere.io
EricElliottJS.com - Learn TDD, functional programming, software design principles and JavaScript with online, interactive lessons. https://ericelliottjs.com
Composing Software eBook: https://leanpub.com/composingsoftware
Composing Software paperback: https://amzn.to/3biid58
Follow me on Twitter / _ericelliott
Follow JS_Cheerleader on Twitter: / js_cheerleader
---
Eric Elliott is the author of the books, “Composing Software” and “Programming JavaScript Applications”. As co-founder of EricElliottJS.com and DevAnywhere.io, he teaches developers essential software development skills. He builds and advises development teams for crypto projects, and has contributed to software experiences for Adobe Systems, Zumba Fitness, The Wall Street Journal, ESPN, BBC, and top recording artists including Usher, Frank Ocean, Metallica, and many more.
He enjoys a remote lifestyle with the most beautiful woman in the world.
#JavaScript #ReactJS #Redux #Code
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: