Skip to content

Fix PlatfromColor issue in TabController.TabBarItem #1955

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

Merged
merged 3 commits into from
Apr 10, 2022

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented Apr 9, 2022

Description

There's a bug when using a color that connected to a PlatformColor in useAnimatedStyle hook.
I opened a issue here that explain it better software-mansion/react-native-reanimated#3164

Anyway, for now, in order to resolve it, I clone the colors in the TabBarItem code.

Changelog

Fix usages of PlatformColor in TabController TabBaritem

@@ -131,6 +131,9 @@ export default function TabBarItem({
const sharedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(labelStyle)));
const sharedSelectedLabelStyle = useSharedValue(JSON.parse(JSON.stringify(selectedLabelStyle)));

const inactiveColor = useRef(_.cloneDeep(labelColor));
const activeColor = useRef(_.cloneDeep(!ignore ? selectedLabelColor : inactiveColor.current));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would give these consts a more specific name like 'animatedLabelColor' and 'animatedSelectedLabelColor' so it will be extra clear what this clone is for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name is suffice, but I will add a note instead that explains the reason we keep it like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note

@Inbal-Tish Inbal-Tish enabled auto-merge (squash) April 10, 2022 06:57
@Inbal-Tish Inbal-Tish merged commit 7eebdf1 into master Apr 10, 2022
@ethanshar ethanshar deleted the fix/TabController_platformColors branch June 13, 2022 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants