목록코딩공부/Redux (2)
개발세발
Redux Toolkit은 적은량의 코드로 같은 기능을 할 수 있도록 해주는 것으로 리덕스의 단점 중의 하나인 보일러 플레이트 코드를 최소화하기 위한 것이다 *보일러 플레이트 Boilerplate code 최소한의 반경으로 여러 곳에서 재사용되며, 반복적으로 비슷한 형태를 띄는 코드 * createAction : function 대신에 createAction으로 자동으로 어떤 타입에 대한 action을 생성하고 payload사용 const INCREMENT = 'counter/increment' function increment(amount) { return { type: INCREMENT, payload: amount, } } const action = increment(3) // { type: 'co..
Redux는 React와 별개인 개념으로 Angular, vue, 그리고 javascript환경에서도 사용할 수 있음 - React와 많이 사용해서 유명했을 뿐 [vanilla js] const add = document.getElementById("add"); const minus = document.getElementById("minus"); const number = document.querySelector("span"); let count = 0; number.innerText = count; const updateText = () => { number.innerText = count; }; const handleAdd = () => { count = count + 1; updateText(); ..