-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I have an issue where updating the object I pass on the custom prop to the motion.div variants doesn't trigger the expected style change.
I created the following sandbox in order to demonstrate the issue:
https://codesandbox.io/s/framer-motion-stale-custom-fibp5?file=/src/App.js
My expectation is that when I toggle the theme - the circle's on/off colors will immediately change based on the new theme. (from black/white to darkblue/yellow and vice versa).
However, the theme changes are applied only once the animation value is changed (status changes from "on" to "off" etc.) So when I toggle the theme, I'm showing a "stale" theme value until I also toggle the status (on/off).
For the moment I'm using a workaround (also suggested on this corresponding stackoverflow thread) where I update the key of the motion.div upon theme change - thus forcing it to re-render - but this feels a bit hacky.
Is this a bug or is something wrong with how I'm using the api?
Any help would be greatly appreciated.