ReactDOM.render(
);
componentWillMount()
render()
직전에 불림.
componentDidmount()
- component가 DOM 에 mount 직후 =>
this
사용 가능함. (this.state
) - Preparation for API usage.
- component가 DOM 에 mount 직후 =>
componentWillReceiveProps()
props
update 시nextProps
와this.props
비교.
componentDidUpdate()
- component re-render 한 직후에 불림.
Redux: Write a Counter with Redux | Learn freeCodeCamp
const INCREMENT = "INCREMENT";
const DECREMENT = "DECREMENT";
const counterReducer = (state = 0, action) => {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
return state - 1;
default:
return state;
}
};
const incAction = () => {
return {
type: INCREMENT
};
};
const decAction = () => {
return {
type: DECREMENT
};
};
const store = Redux.createStore(counterReducer);