Giter VIP home page Giter VIP logo

vanilla-redux's Introduction

Vanilla-Redux

Learning Vanilla-Redux and React-Redux

store

reducer

action : redux에서 function을 부를 때 쓰는 두번째 parameter

그래서 어떻게 reducer에게 action을 보낼 수 있지?

store.dispatch({ type : "HELLO" }) 이런식으로 보낸다.

const reducer = (state, action) => { if(action.type === "HELLO"){ ... } }

=>

if대신 switch 쓰자

switch(action.type) { case "ADD" : return count + 1; case "MINUS" : return count - 1; default : return count; }

action은 무조건 type이 있어야한다!!

subscribe는 우리에게 store안에 있는 변화들을 알 수 있게 해줘

const onChange = () => { console.log("there was a change!!!") }

store.subscribe(onChange);

state를 mutate(변형) 해서는 안돼 (array.push(action.text)와 같은 것은 변형이다.)

return [...state, {text: action.text}] : 새 state를 return 시켜줘야 한다.!!!!! 중요!!!

vanilla-redux's People

Contributors

kbu715 avatar

Watchers

 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.