[React] React state
리액트 공식 문서 참고! !
그냥 적으면서 공부하는 느낌으로 사이트 내용을 쭉 적어보겠다
State can hold any kind of JavaScript value, including objects. But you shouldn't change objects
that you hold in the React state directly. Instead, when you want to update an object, you nedd to
create a new one (or make a copy of an exisitng one), and then set the state to use that copy.
Consider an object in state:
const [position, setPosition] = userState({ x : 0, y : 0});
Technically, it is possible to change the contents of the object itself. This is called a mutation:
position.x = 5;
However, although objects in React state are technically mutable, you should treat them as if they were
immutable - like numbers, booleans, and strings. Instead of mutating them, you should always replace them.
하핫 근데 글이 너무 길다
이 밑은 다음에 또 읽고 정리해보겠숩니다