Sign in Go Pro

React Native with Redux

Refactoring Action Creators and Action Types

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

Actions are usually returned from functions called action creators. You can define actions inline, but they are usually extracted to separate files, and are returned from functions defined in those action files.

We'll take the add todo action which we were defining inline, and define it in an action creator instead. Then, we'll extract the action types to their own file.

Extracting action types isn't a necessary step, but it does provide protection from duplicate action names, as well as protection from circular dependencies.

Summary of Content:

  • Create a new actions folder to hold action creators
  • Create a new action creator which returns the ADD_TODO action
  • Create a new types file, and extract the ADD_TODO constant to that file

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in React Native with Redux