Open
Description
Summary
스택의 children 에 리렌더링이 일어날 때 원하지 않는 spacing 이 주입될 수 있습니다.
Reproduction process
Stack
이 spacing
을 받아서 StackItem
의 marginBefore
로 넘기는 조건으로, StackItem
이 첫 번째 React element 보다 뒤에 있는지를 판단하고 있습니다. 이 때 useRef
로 index
를 저장하고 있다 보니 children
이 리렌더링이 일어나서 바뀌더라도 index
가 갱신되지 않습니다. 예를 들면 다음과 같은 상황입니다.
리렌더링 전
<Stack spacing={2}>
<StackItem>1<StackItem>
<StackItem>2<StackItem>
</Stack> // firstValidElementIdx.current = 0
리렌더링 후
<Stack spacing={2}>
false
<StackItem>2<StackItem>
</Stack> // firstValidElementIdx.current 는 여전히 0 이므로 첫 번째 StackItem 에 marginBefore 가 들어감
Version of bezier-react
1.7.1
Browser
No response
Operating system
- macOS
- Windows
- Linux
Additonal Information
No response
Activity