- Build out action creators that return the correct data.
- Create actions to read, create, and destroy data.
If you haven't already, make sure to run npm install -g webpack-dev-server
to get the webpack dev server installed on your machine.
Note: If you're on the Learn IDE, this will have already been done for you.
Imagine we're building a movie app for users to keep track of their favorite movies. We'll be building out action creator functions so that the user can take the following actions.
- Add a new movie
- Delete an existing movie
- Update their username
- Reset their username to the default username of 'default'
Make sure that you run npm install
first.
In one terminal instance run npm start
, and in a second terminal instance run npm run test:watch
. This will start your Webpack Dev Server and your test suite that watches your code. Open the web browser and go to the port specified in the Webpack Dev Server. (ex. http://localhost:8080)
Note: If you're using the Learn IDE, you can use jobs rather than multiple terminals.
By convention in Redux, we write our action creator functions in a folder called actions
. For a small project, we can define all of the actions in a single file file called index
and export them as named exports.
For example:
// src/actions/index.js
export function incrementCount(){
return {
type: 'INCREMENT_COUNT'
}
}