You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the theme prop or the values inside the theme object changes, calendar doesn't update the UI based on the new theme values. In my case, when the device scheme changes from light to dark, I change the theme prop but it doesn't update the calendar. I have to do a full unmount & mount of the <Calendar /> component in order to see the theme changes.
Expected Behavior
When theme prop changes, <Calendar /> component should re-render with the new changes
Observed Behavior
What actually happened when you performed the above actions?
When I change the dayTextColor value inside the theme prop from white to black, it stays white until I unmount & re-mount the component.
Environment
Please run these commands in the project folder and fill in their results:
This problem happens because theme prop is used as initialValue of useRef. So when the theme prop changes, the changes doesn't affect the component. For example, take a look at day/basic component:
Description
When the
theme
prop or the values inside thetheme
object changes, calendar doesn't update the UI based on the new theme values. In my case, when the device scheme changes from light to dark, I change thetheme
prop but it doesn't update the calendar. I have to do a full unmount & mount of the<Calendar />
component in order to see the theme changes.Expected Behavior
When
theme
prop changes,<Calendar />
component should re-render with the new changesObserved Behavior
What actually happened when you performed the above actions?
When I change the
dayTextColor
value inside thetheme
prop fromwhite
toblack
, it stayswhite
until I unmount & re-mount the component.Environment
Please run these commands in the project folder and fill in their results:
npm ls react-native-calendars
:[email protected]
npm ls react-native
:[email protected]
Also specify:
iOS Simulator - iPhone 16 Pro - iOS 18.0
Reproducible Demo
Screenshots
Current:
What should be (I fixed it with a patch):
Solution
This problem happens because
theme
prop is used asinitialValue
ofuseRef
. So when thetheme
prop changes, the changes doesn't affect the component. For example, take a look atday/basic
component:To fix this I added a
useEffect
that when thetheme
prop changes, it updates thestyle
ref:With this addition, the issue is fixed as you can see in the second GIF above.
I will create a PR for it.
The text was updated successfully, but these errors were encountered: