Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: change opacity for hidden tabs only when not using rn-screens (#80)
Browse files Browse the repository at this point in the history
When using react-native screens we don't need to hide invisible tabs using opacity. This in conjunctions with "active" property normally used by screens where causing blinking effect when new tabs got activated as in some cases opacity would update in a different UI transaction (this would only surface on Android).

This change removes the use of `opacity` style when react-native-screens are active and solely relies on `active` property in that case. When rn-screens are off we fallback to rendering `View` and use `opacity` as before (this is now done in `ResourceSavingScene`).

### Motivation

Fix blinking effect on Android when switching tabs [#5382](react-navigation/react-navigation#5382)

### Test plan

1) Run RN-screens sample app with and w/o screens enabled or try the code from this snack -> https://snack.expo.io/rklSkM-xE
2) Try this on a low end Android device for consistent repro
3) Switch between tabs and see the content disappear for one frame with screens ON when this change isn't active and see this issue gone with this change applied
  • Loading branch information
kmagiera authored and satya164 committed Aug 18, 2019
1 parent c80654e commit 6490049
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ class TabNavigationView extends React.PureComponent<Props, State> {
return (
<ResourceSavingScene
key={route.key}
style={[
StyleSheet.absoluteFill,
{ opacity: isFocused ? 1 : 0 },
]}
style={StyleSheet.absoluteFill}
isVisible={isFocused}
>
{renderScene({ route })}
Expand Down
2 changes: 1 addition & 1 deletion packages/bottom-tabs/src/views/ResourceSavingScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class ResourceSavingScene extends React.Component<Props> {

return (
<View
style={[styles.container, style]}
style={[styles.container, style, { opacity: isVisible ? 1 : 0 }]}
collapsable={false}
removeClippedSubviews={
// On iOS, set removeClippedSubviews to true only when not focused
Expand Down

0 comments on commit 6490049

Please sign in to comment.