Skip to content

Commit

Permalink
fix(progress-steps): unnecessary re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
krisantrobus committed Nov 21, 2024
1 parent a720e5e commit ef7f872
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-rabbits-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@twilio-paste/progress-steps": patch
"@twilio-paste/core": patch
---

[ProgressSteps] fixed an issue where progress steps was rerendering unnecessarily
7 changes: 7 additions & 0 deletions internal-docs/engineering/gotchas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Gotchas

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.

## Emotion Library

* 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.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ const ItemSeparatorStyles: {

export const ProgressSteps = React.forwardRef<HTMLDivElement, ProgressStepsProps>(
({ element = "PROGRESS_STEPS", orientation = "horizontal", ...props }, ref) => {
const ContainerStyled = styled.div(
css({
display: "flex",
...ItemSeparatorStyles[orientation],
}),
const ContainerStyled = React.useMemo(
() =>
styled.div(
css({
display: "flex",
...ItemSeparatorStyles[orientation],
}),
),
[orientation],
);

return (
Expand Down

0 comments on commit ef7f872

Please sign in to comment.