Skip to content

Commit 130cfbc

Browse files
committed
[fix] Fix transition blink on Android
1 parent 7b72fa4 commit 130cfbc

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [Unreleased]
22

3-
# [3.1.1](https://github.com/IjzerenHein/react-navigation-shared-element/compare/v2.3.0...v3.1.1) (2021-08-19)
3+
# [3.1.2](https://github.com/IjzerenHein/react-navigation-shared-element/compare/v2.3.0...v3.1.2) (2021-08-19)
44

55
### Features
66

@@ -12,9 +12,13 @@
1212
### Breaking changes
1313

1414
- React navigation 4 is now supported through the `createSharedElementStackNavigator/build/v4` import
15-
- `sharedElements` function replaces `navigation/otherNavigation` by `route/otheRoute` arguments
15+
- `sharedElements` function replaces `navigation/otherNavigation` by `route/otherRoute` arguments
1616
- See migration guide in `./docs/Migration.md` for upgrading instructions
1717

18+
### Bug Fixes
19+
20+
- Fixes blink artefact on Android transitions (disables `detachInactiveScreens` by default on Android)
21+
1822
# [2.3.0](https://github.com/IjzerenHein/react-navigation-shared-element/compare/v2.2.0...v2.3.0) (2020-04-13)
1923

2024
### Features

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,10 @@ The following versions or react-navigation and the stack navigator are supported
2121
| [2.x](https://github.com/IjzerenHein/react-navigation-shared-element/tree/v2) | 3 & 4 | This version is compatible with `react-navigation-stack@2`. |
2222
| [1.x](https://github.com/IjzerenHein/react-navigation-shared-element/tree/v1) | 3 & 4 | This version is compatible with `react-navigation-stack@1`. |
2323

24-
Not supported:
24+
## Things to know
2525

26-
- [ ] [react-native-screens/createNativeStackNavigator](https://github.com/IjzerenHein/react-navigation-shared-element/issues/14)
27-
28-
## Known issues
29-
30-
Navigating to a screen on Android causes the target element to blink when unhiding. This problem needs to be investigated further, but can be worked around by [disabling `react-native-screens` explicitly](./example/src/App.tsx#L50-L55).
31-
32-
```jsx
33-
import { Platform } from 'react-native';
34-
35-
// As of react-native-screens@2.14.0, enableScreens causes a fade-in of the image when navigating to a screen.
36-
// And as of react-native-screens@3, enableScreens is enabled by default.
37-
// Disable screens on Android until this issue has been resolved.
38-
enableScreens(Platform.OS !== "android");
39-
```
26+
- `react-navigation-shared-element` uses the [JS based Stack Navigator](https://reactnavigation.org/docs/stack-navigator). The [Native Stack Navigator](https://reactnavigation.org/docs/native-stack-navigator) is not yet supported and it is not yet clear whether this can be supported in the future.
27+
- On [detaching inactive screens](https://reactnavigation.org/docs/stack-navigator/#detachinactivescreens) a blink may occur on Android. Because of this `detachInactiveScreens` is set to `false` by default on Android.
4028

4129
## Demo App
4230

example/src/App.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ if (Platform.OS === "android") {
4747
StatusBar.setBackgroundColor("transparent");
4848
}
4949

50-
// As of react-native-screens@2.14.0, enableScreens causes
51-
// a fade-in of the image when navigating to a screen.
52-
// And as of react-native-screens@3, enableScreens is enabled by default.
53-
// Therefore, explicitly disable screens on Android until this issue
54-
// has been resolved.
55-
enableScreens(Platform.OS !== "android");
56-
5750
export default () => (
5851
<SafeAreaProvider>
5952
<Tests>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-navigation-shared-element",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "react-native-shared-element bindings for React Navigation",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

src/createSharedElementStackNavigator.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default function createSharedElementStackNavigator<
128128
return (
129129
<SharedElementRendererContext.Provider value={rendererDataProxy}>
130130
<StackView
131+
detachInactiveScreens={Platform.OS !== "android"}
131132
{...rest}
132133
state={state}
133134
descriptors={descriptors}

src/v4/createSharedElementStackNavigator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import hoistNonReactStatics from "hoist-non-react-statics";
22
import * as React from "react";
3+
import { Platform } from "react-native";
34
import {
45
NavigationNavigator,
56
NavigationProp,
@@ -85,6 +86,7 @@ function createSharedElementStackSceneNavigator(
8586
}
8687

8788
return createStackNavigator(wrappedRouteConfigs, {
89+
detachInactiveScreens: Platform.OS !== "android",
8890
...stackConfig,
8991
defaultNavigationOptions:
9092
typeof defaultNavigationOptions === "function"

0 commit comments

Comments
 (0)