-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Not re-rendering on theme prop changes #2539
Comments
I added PR to fix this: |
This helped a lot, thanks |
I patched my version with your changes but i doesn't update at the first time:
This is the update function:
Its updating late, if i select a date outside the range, it will keep the bg color as the same, next time i press another day, it changes.. any solution? thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: