Skip to content

Commit 7f39856

Browse files
authored
fix(progress-steps): unnecessary re-renders (#4170)
1 parent a720e5e commit 7f39856

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.changeset/nervous-rabbits-love.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@twilio-paste/progress-steps": patch
3+
"@twilio-paste/core": patch
4+
---
5+
6+
[ProgressSteps] fixed an issue where progress steps was rerendering unnecessarily
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Gotchas
2+
3+
The purpose of this document is to keep a list of niche issues that have arisen over the lifetime of the product that we do not want to re-introduce. This can be related to our coded or third party libraries.
4+
5+
## Emotion Library
6+
7+
* If you pass a prop of the component into `styled.div` be sure to wrap it in useMemo as this librabry causes unnecessary re-renders otherwise.

packages/paste-core/components/progress-steps/src/ProgressSteps.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,15 @@ const ItemSeparatorStyles: {
8989

9090
export const ProgressSteps = React.forwardRef<HTMLDivElement, ProgressStepsProps>(
9191
({ element = "PROGRESS_STEPS", orientation = "horizontal", ...props }, ref) => {
92-
const ContainerStyled = styled.div(
93-
css({
94-
display: "flex",
95-
...ItemSeparatorStyles[orientation],
96-
}),
92+
const ContainerStyled = React.useMemo(
93+
() =>
94+
styled.div(
95+
css({
96+
display: "flex",
97+
...ItemSeparatorStyles[orientation],
98+
}),
99+
),
100+
[orientation],
97101
);
98102

99103
return (

0 commit comments

Comments
 (0)