redux

김혁중·2022년 5월 16일
0

React

목록 보기
8/10

참고 생활코딩

  • userState 대용
    const [number, setNumber] = useState(1)
npm install redux react-redux

import { createStore } from 'redux'
import { Provider, useSelector, useDispatch } from 'react-redux'

function reducer(currentState, action) {
  if(currentState === undefined) {
    return {
      number: 1
    }
  }
  const newState = {...currentState}
  return newState
}

const store = createStore(reducer)
profile
Digital Artist가 되고 싶은 초보 개발자

0개의 댓글