Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CodeRoad tutorial for learning Redux

NotificationsYou must be signed in to change notification settings

ShMcK/coderoad-redux-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ACodeRoad tutorial for learning Redux.

CodeRoad

CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. Learn more atCodeRoad.io.

Setup

  • install the tutorial package

    npm install --save coderoad-redux-js

  • install and run theatom-coderoad plugin

Outline

Project Setup

Getting a project setup is rarely easy. Luckily, we have a quick script that can do the work for us.


Running> npm run setup will do the following:

  1. Install package dev dependencies
  2. Create an output directory called "dist"
  3. Install "concurrently" & "browser-sync" globally
  4. Run our app in the browser

You'll find this "setup" script located in yourpackage.json.


We'll be installing a lot of scripts from terminal. You may also want to consider installing the atom package"platformio-ide-terminal", which provides a terminal inside your editor.

The Store

The "single source of truth".

conststore=createStore(reducer,initialState);
Actions

Events that change the data.

1. Actions
constaction={type:'ACTION_NAME'};
2. Action Creators
constactionName=()=>({type:'ACTION_NAME'});
3. Action Types
constACTION_NAME='ACTION_NAME'
Reducer

The data transformation

constreducer=(state)=>{console.log(state);returnstate;};
Pure Functions

Reducers must be pure functions

State is "read only".

Notes

constnextPokemon=state.pokemon.map(p=>{if(id===p.id){p.votes+=1;}returnp;});return{pokemon:nextPokemon};
Combine Reducers

Create modular, composable reducers withcombineReducers.

About

CodeRoad tutorial for learning Redux

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp