Giter Site home page Giter Site logo

web-reduxfundamentalsi-guided-project's Introduction

How to Run this App

  • Clone repository.
  • Run npm install or yarn install.
  • Run npm run dev or yarn dev.
  • Run npm test or yarn test.
  • Serve index.html using live-server or similar.

Objectives

  • Learn the fundamentals of Redux.

Requirements

We need node & npm. VSCode's eslint extension is recommended. Command line commands are run inside the project folder. This guide uses npm but should work the same using yarn.

Steps

  • Install the project and install redux devtools.
  • React docs: lifting state up.
  • Limitations and problems when lifting state up.
  • Flesh out example using react component state:
  • A Person component has physicalHealth and mentalHealth slices of state.
  • There is a winLottery method that improves both slices of state.
  • There is a slipOnBananaPeel method that worsens physicalHealth.
  • There is a watchTheNews method that worsens mentalHealth.
  • Start a redux store in App.jsx initializing hard-coded physicalHealth and mentalHealth.
  • Wrap Container inside App.jsx with the Provider given by react-redux, passing the store.
  • See redux devtools working with the hard-coded slices.
  • Create reducing functions for each slice of state explaining requisites for reducers.
  • Refactor App.jsx to use combineReducers and the new functions.
  • Refactor Person to delete local state and this.setState logic.
  • Connect the Person component to have access to the store.
  • Refactor Person to dispatch SLIP_ON_BANANA etc using this.props.dispatch.
  • Refactor Person to use pre-defined action creators.
  • Explain mapStateToProps.

web-reduxfundamentalsi-guided-project's People

Contributors

ladrillo avatar

Stargazers

 avatar

Watchers

James Cloos avatar Austen Allred avatar  avatar

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.