React Redux Tutorials - 5 - Actions

jh22j9·2020년 10월 13일
0

React Redux Tutorials

목록 보기
5/20

Actions


  • The only way your application can interact with the store.
  • Carry some information from your app to the redux store.
  • Plain JavaScript objects.
  • Have a type property that indicates the type of action being performed.
  • The type property is typically defined as a string constants.
// (1) define a string constant(to avoid spelling mistake)
const BUY_CAKE = 'BUY_CAKE' 

// (2) define an action
// action 객체의 형태적 제한사항은 type 프로퍼티를 가져야한다는 것 외에는 없다.
{
  type: BUY_CAKE,
  info: 'first redux action'
}

// (3) implement an action creator(function that returns an action) - replaces step (2)
function buyCake() {
  return {
    type: BUY_CAKE,
    info: 'first redux action'
  }
}

왜 action creator의 형태로 작성해야 할까?

🔗 Why action creators?

0개의 댓글

관련 채용 정보