Coder Social home page Coder Social logo

28_intro_redux's Introduction

Post-lecture Challenges

  1. Add buttons to our Counter component to decrement the count and reset the count (Decrement should subtract by 1, reset should set the count to zero.)
  • To do this, you should dispatch a different action whenever the button is clicked.
  1. Create a new component to represent a note list. This component should render out a list of notes from the noteStore.
  2. Add an form with an input for note. When the form is submitted, we should add that note into the state and re-render our NoteList component.

NOTES

  1. What is Redux?
  • A predictable state container for JS apps
  • Gives us a single source of truth for our application state
  • Gives us predictable state-tree - the state is immutable
  1. Why does Redux exist?
  • Keeping track of application state is really hard
  • In React, components have to pass props down many levels
  1. What are the principles of Redux?
  • State changes should be predictable - the state should not be mutated
  • We will update our state using pure functions
    • non destructive, returns the same thing every time
  1. What are the different pieces / components of Redux?
  • store
    • plain old javascript object
    • keeps track of the current state
    • we can give this to different components to let them have access to the data
    • will have methods to update the state and then fire off any other functions that we want
  • reducers
    • a pure function takes in an action and the current state and returns the new state
  • actions
    • something that describes that a state change should occur
    • in Redux, we represent these as plain old javascript objects
    • each one has a type: {type: 'INCREMENT_COUNT'}

28_intro_redux's People

Contributors

ipc103 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.