Autoplay

    Introducing Reduce Redux Boilerplate with Redux-Actions

    Andy Van SlaarsAndy Van Slaars

    One of the biggest complaints people tend to have about Redux is the amount of boilerplate code you end up writing to use it. It doesn't have to be that way!

    Redux actions will simplify the code for our action creators and even give us a new way to create our reducers.

    By using redux-actions, our application will use Flux Standard Actions, keeping the way we manage our state more consistent.

    This small library only exposes a few functions for its API, so it won't take long to learn, but it will make a huge difference in how we write action creators and reducers for redux.

    reduxRedux
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    Instructor: 00:00 One of the biggest complaints people tend to have about Redux is the amount of boilerplate code you end up writing to use it. It doesn't have to be that way.

    00:08 In this course, we'll start with a fully functioning react and Redux application. This application is wired up with constants for our actions, action creators, reducer using a switch statement like you would expect, and redux func middleware for handling async actions.

    00:21 We've cut down on the cognitive overload a bit by colocating action constants creators and the reducer code but worry factor this even further. We'll install the Redux actions library as a dependency, and look at it small, but powerful API. Redux actions will simplify the code for our action creators, and even give us a new way to create our reducers.

    00:42 By using Redux actions or application we use Flux standard actions. Keeping the way, we manage our state more consistent. With that consistency, we'll open up capabilities to enhance on reducer to handle errors within the context of specific actions.

    00:56 We'll also cover how to attach metadata to our actions without adding clutter to our payloads. This small library only exposes a few functions for its API, so it won't take long to learn, but it will make a huge difference in how we write action creators and reducers for Redux.

    Discuss

    Discuss