Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Building Applications with React and Redux Actions, Dispatch, and Reducers. Oh my! Intro to Reducers

Ari Misha
Ari Misha
19,323 Points

Issues with ActionTypes

Okay so we created this file called "Player.js" in "actiontypes" directory which exports bunch constants, and these constants are equal to some path which doesnt even exist yet. I mean whole thing doesnt make sense at all. Can someone point me to right direction please? Tank you so much in advance!

Here is my "src/actiontypes/Player.js" file:

export const ADD_PLAYER = 'player/ADD_PLAYER';
export const REMOVE_PLAYER = 'player/REMOVE_PLAYER';
export const UPDATE_PLAYER_SCORE = 'player/UPDATE_PLAYER_SCORE';

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Think of actions as messages sent to the reducers and the action type is the "what to do" part of the message. They are simple string constants. Using constants helps keep them maintainable and avoids typos in retyping them. They are not paths or anything. They can be arbitrary strings but they will be displayed in Redux Dev Tools so it's best that they be descriptive.

Ari Misha
Ari Misha
19,323 Points

Thank you so much Seth Kroger! I think i get it now (: