Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Redux

You're reading from   Learning Redux Write maintainable, consistent, and easy-to-test web applications

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781786462398
Length 374 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Daniel Bugl Daniel Bugl
Author Profile Icon Daniel Bugl
Daniel Bugl
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Why Redux? 2. Implementing the Elements of Redux FREE CHAPTER 3. Combining Redux with React 4. Combining Redux with Angular 5. Debugging a Redux Application 6. Interfacing with APIs 7. User Authentication 8. Testing 9. Routing 10. Rendering on the Server 11. Solving Generic Problems with Higher-Order Functions 12. Extending the Redux Store via Middleware

Implementing actions and action creators

In the first chapter, we learned how important actions are in Redux. Only actions can change the state of your application.

Actions in Redux are valid if they have a type property. The rest of the object structure is totally up to you. If you prefer using a standard structure, check out https://github.com/acdlite/flux-standard-action.

Redux actions are simple JavaScript objects with a type property, which specifies the name of the action.

Let's define a simple action, in the src/index.js file:

const createPost = { type: 'CREATE_POST', user: 'dan', text: 'New post' }
console.log(createPost)

Now, save the file. Webpack should automatically refresh the page after modifying and saving a source file (such as src/index.js).

...
You have been reading a chapter from
Learning Redux
Published in: Aug 2017
Publisher: Packt
ISBN-13: 9781786462398
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime