Coder Social home page Coder Social logo

react-redux-actions-and-action-creators-lab's Introduction

Lights...Camera...Action!

Camera

Objectives

  1. Build out action creators that return the correct data.
  2. Create actions to read, create, and destroy data.

Instructions

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.

  1. Add a new movie
  2. Delete an existing movie
  3. Update their username
  4. Reset their username to the default username of 'default'

How to run webpack server and tests

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.

But Where Do I Write My Code?

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'
  }
}

react-redux-actions-and-action-creators-lab's People

Contributors

aturkewi avatar gj avatar ipc103 avatar jjseymour avatar lukeghenco avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-redux-actions-and-action-creators-lab's Issues

Typo

screen shot 2016-12-14 at 8 52 06 am

type with npm install

How to run tests in browser?

Hey @jjseymour I'm having some issues running the tests in browser and wanted to check with you.

Line 11 of the index.html file instructs that you can run these tests in browser (as I've seen done with many of the other mocha test labs) by running mocha.run() from the console of the index page. I'm getting an error when I load the index page:

Uncaught SyntaxError: Unexpected token import           index-test.js:1 

Do the test files have to be added to the webpack config or something? @Lukeghenco thought that this might have been cause from using an old template?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.