1주차 질답 #22
Replies: 6 comments 7 replies
-
4번 질문
|
Beta Was this translation helpful? Give feedback.
-
1번
|
Beta Was this translation helpful? Give feedback.
-
6번 질문Q. 지역 상태를 효과적으로 사용하는 방법 중에서 불필요한 리렌더링을 방지하기 위해 어떤 방법을 사용할 수 있을까요? const Parent = () => {
const [count, setCount] = useState(0);
return(
<>
<Child1 count={count} />
<NoEffect />
</>
);
}; |
Beta Was this translation helpful? Give feedback.
-
3번 질문아래 코드에서, 버튼을 빠르게 두 번 클릭했을 때 1번 코드와 2번 코드의 동작에서의 차이와, 그 이유를 말씀해주세요. // 어떤 컴포넌트 내부
const [count, setCount] = useState(0);
const handleClickAddCount = () => {
// 1번
setCount((count) => count + 1);
// 2번
setCount(() => count + 1);
};
return <button onClick={handleClickAddCount}>버튼</button>; |
Beta Was this translation helpful? Give feedback.
-
5번Q1. 지역 상태를 언제 사용해서는 안될까요?Q2. 다음 예제에서 버튼을 클릭하면 화면상에 변화가 없는 이유가 무엇일까요?const Component = () => {
const [state, setState] = useState({count: 0})
return <div>
<button onClick={() => setState({count:1})}>
{state.count}
</button>
</div>
} |
Beta Was this translation helpful? Give feedback.
-
7번 질문
const init = () => 0;
const Component = () => {
const [count, setCount] = useState(init);
return (
<div>
{count}
<button onClick={(c) => setCount(c + 1)}>
Increment Count
</button>
</div>
);
};
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions