Skip to content

Commit

Permalink
fix(theme): correctly disable animations on mount (#2021)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSisb committed Nov 10, 2021
1 parent cbdb3cb commit 8bedb9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/stupid-buttons-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@twilio-paste/customization': patch
'@twilio-paste/theme': patch
'@twilio-paste/core': patch
---

[Theme and Customization] Slight tweak to prevent animations from running once on app load when they should be disabled from the beginning.
4 changes: 2 additions & 2 deletions packages/paste-customization/src/CustomizationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const CustomizationProvider: React.FC<CustomizationProviderProps> = ({
);

const prefersReducedMotion = useReducedMotion();
React.useEffect(() => {
React.useLayoutEffect(() => {
AnimatedGlobals.assign({
skipAnimation: disableAnimations || prefersReducedMotion,
});
}, [prefersReducedMotion]);
}, [disableAnimations, prefersReducedMotion]);

return (
<StyledThemeProvider theme={customTheme}>
Expand Down
4 changes: 2 additions & 2 deletions packages/paste-theme/src/themeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ const ThemeProvider: React.FunctionComponent<ThemeProviderProps> = ({
...props
}) => {
const prefersReducedMotion = useReducedMotion();
React.useEffect(() => {
React.useLayoutEffect(() => {
AnimatedGlobals.assign({
skipAnimation: disableAnimations || prefersReducedMotion,
});
}, [prefersReducedMotion]);
}, [disableAnimations, prefersReducedMotion]);

const providerThemeProps = getProviderThemeProps(theme, customBreakpoints);

Expand Down

0 comments on commit 8bedb9f

Please sign in to comment.