type
property that indicates the type of action being performed.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의 형태로 작성해야 할까?