Prevent React component subtrees from rendering using Suspense. Current stable version is 1.0.4. React Freeze allows freezing parts of the component tree without unmounting, preserving React state and native views (e.g., scroll position, input state, loaded images). It leverages React 17+'s Suspense mechanism and is primarily used with React Navigation in React Native to avoid unnecessary re-renders of hidden screens. Unlike simple conditional rendering, it retains DOM/native instances. Requires React >=17 and React Native >=0.64. Maintained by Software Mansion, the team behind react-native-screens and react-native-reanimated.
npm install react-freezeVerified import paths — ran on the pinned version, not inferred.
Shows how to wrap a component tree with Freeze and conditionally freeze it based on a prop, preventing re-renders when hidden.
Ensure side effects that require cleanup are not dependent on freeze/unfreeze cycles; consider using alternative patterns.
Use <Freeze freeze={...}> directly in your components or navigate using react-native-screens' newer API.Upgrade React to version 17 or higher.
Test gesture interactions thoroughly; future versions may improve this.
Upgrade React Native to 0.64+.
Upgrade React to version 17 or higher using: npm install react@17 react-dom@17
Upgrade React Native to 0.64+ and React to 17+.
Change to: import { Freeze } from 'react-freeze'Import enableFreeze from 'react-native-screens' (v3.9.0+).