How to Clear Cache in React Native

Rana Hasnain Khan Feb 02, 2024
How to Clear Cache in React Native

We will introduce the simplest ways to clear cache in a React Native project.

Simplest Ways to Clear Cache in React Native

There are different caches in React Native apps, such as packager cache, emulator cache, Gradle cache, and npm cache. These are useful sometimes, and sometimes we want to remove them to test applications at different points.

There’s a simple way to reset your cache with one command. If you want to remove cache using React Native, use the following command.

# react native
react-native start --reset-cache

This command will start our React Native application while clearing all the caches.

If we want to remove cache using npm, we can use the following command.

# npm
npm start -- --reset-cache

This command will also start our React Native application while clearing all the caches.

Or, if we are using expo to build our React Native application, we can use the following command.

# expo
expo start -c

In this code, c is a shorthand for cache, and it will start our application clearing all the caches.

If we use yarn, we can use the following command to clear our cache.

# yarn
yarn cache clean

This command will start our React Native application while cleaning all the caches.

Rana Hasnain Khan avatar Rana Hasnain Khan avatar

Rana is a computer science graduate passionate about helping people to build and diagnose scalable web application problems and problems developers face across the full-stack.

LinkedIn

Related Article - React Native