---
title: "Avoid Android back button crash with PSPDFKit"
canonical_url: "https://www.nutrient.io/guides/react-native/troubleshooting/handling-back-navigation-with-react-native-screens/"
md_url: "https://www.nutrient.io/guides/react-native/troubleshooting/handling-back-navigation-with-react-native-screens.md"
last_updated: "2026-06-19T19:49:29.209Z"
description: "Learn how to prevent app crashes on Android when using NutrientView with a hardware back button in React Native."
---

# Fixing Android back button crash with Nutrient

On Android, calling `Navigation#goBack()` or using a hardware back button to navigate back from a screen with a `NutrientView` causes the app to crash when using `react-native-screens`. This is caused by a [known issue](https://github.com/software-mansion/react-native-screens/issues/1300) in `react-native-screens` where it tries to redraw the view when it has already been recycled.

To address this issue, we added a `destroyView()` function to `NutrientView`, which should be called before navigation happens to destroy the `NutrientView` and avoid the redraw, in turn avoiding the crash.

The code snippet below shows how to intercept the back navigation and use the `destroyView()` function to stop the crash:

```js

import React from 'react';
import NutrientView from '@nutrient-sdk/react-native';
import { View } from 'react-native';

const DOCUMENT = 'file:///android_asset/report.pdf';

export default function PDFScreen({ navigation }) {
	// This holds the reference to the `NutrientView`.
	var pdfRef: React.RefObject<NutrientView | null> = React.createRef();

	// Intercept the back button and destroy the `NutrientView` before performing navigation.
	React.useEffect(() =>
		navigation.addListener('beforeRemove', (e) => {
			// Destroy the view before the screen is removed.
			pdfRef.current.destroyView();
		}),
	);

	return (
		<View style={{ flex: 1 }}>
			<NutrientView
				ref={pdfRef}
				document={DOCUMENT}
				style={{ flex: 1 }}
			/>
		</View>
	);
}

```
---

## Related pages

- [Android Gradle Plugin Requires Java 11](/guides/react-native/troubleshooting/android-gradle-plugin-requires-java-11.md)
- [Guide to adding a Nutrient license key in React Native](/guides/react-native/troubleshooting/add-license-key.md)
- [How to find your iOS app bundle ID easily](/guides/react-native/troubleshooting/finding-the-bundle-id.md)
- [Find out your Nutrient version easily](/guides/react-native/troubleshooting/getting-the-currently-used-version.md)
- [Troubleshooting](/guides/react-native/troubleshooting.md)
- [Fix new architecture build issues in React Native](/guides/react-native/troubleshooting/new-architecture-build-issues.md)
- [Nightlies](/guides/react-native/troubleshooting/nightlies.md)
- [Out Of Memory Error React Native Android](/guides/react-native/troubleshooting/out-of-memory-error-react-native-android.md)
- [NutrientView inside a modal is blank or crashes on Android](/guides/react-native/troubleshooting/nutrientview-modal-android.md)
- [Textinput Error React Native Android](/guides/react-native/troubleshooting/textinput-error-react-native-android.md)
- [React Navigation](/guides/react-native/troubleshooting/react-navigation.md)
- [Understanding app IDs in Android development](/guides/react-native/troubleshooting/what-is-an-app-id.md)
- [Understanding bundle IDs for iOS app development](/guides/react-native/troubleshooting/what-is-a-bundle-id.md)
- [Managing Nutrient's render cache effectively](/guides/react-native/troubleshooting/outdated-render-cache.md)
- [View controller-based status bar appearance](/guides/react-native/troubleshooting/view-controller-based-status-bar-appearance.md)
- [Fix Xcode error code 65 for React Native on M1 Macs](/guides/react-native/troubleshooting/xcode-error-65-missing-required-target-architectures-react-native.md)
- [CMake/Ninja build error caused by long file paths on Windows](/guides/react-native/troubleshooting/windows-path-length-cmake-error.md)

