npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-restart-app

v1.0.7

Published

A simple module to restart a React Native app

Downloads

534

Readme

react-native-restart-app

A simple module to restart your React Native app programmatically. This module works on both iOS and Android platforms, providing a unified API to restart the application when needed, such as after a configuration change or an error recovery action.

Table of Contents

  1. Description
  2. Installation
  3. Usage

Description

react-native-restart-app allows you to restart your app from the code, which is especially useful when applying significant changes such as language updates, theme switching, or reloading configurations without requiring the user to manually restart the application.

Installation

React Native >= 0.60

For React Native version 0.60 and above, auto-linking will handle the linking of the library. Simply run the following command to install the module:

npm install react-native-restart-app
# or
yarn add react-native-restart-app

Run pod install in the ios directory to install the necessary pods:

cd ios/
pod install

Extra Step for React Native <= 0.67

For React Native versions 0.67 and below, you need to add an extra step in the Podfile:

Add the following to your Podfile:

pod 'react-native-restart-app', :path => '../node_modules/react-native-restart-app'

Then, run pod install in the ios directory to install the necessary pods:

cd ios/
pod install

Build your project using Xcode or via CLI:

npx react-native run-ios

Manual iOS Installation

If auto-linking is not supported or you are using an older version of React Native (<0.60), you can manually link the library.

  1. Open your project in Xcode and find the Libraries folder.
  2. Right-click the folder and select "Add Files to [Your Project]".
  3. Navigate to node_modules/react-native-restart-app/ios/ and add RNRestart.xcodeproj.
  4. In the "Build Phases" section of your project settings, add libRNRestart.a to "Link Binary With Libraries".
  5. Perform a clean build with Xcode (Cmd + Shift + K) and then build the app again (Cmd + B).

Manual Android Installation

For Android, manual linking can be performed as follows:

  1. Open android/settings.gradle and add:

    include ':react-native-restart-app'
    project(':react-native-restart-app').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart-app/android')
  2. In android/app/build.gradle, add the following line inside the dependencies block:

    implementation project(':react-native-restart-app')
  3. Open MainApplication.java and import the package:

    import com.reactnativerestartapp.RNRestartPackage;
  4. Then, add the package to your getPackages method:

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNRestartPackage() // Add this line
        );
    }

Usage

To use react-native-restart-app, import it into your component and call the restart method when needed.

import restart from 'react-native-restart-app';

// Example: Restart the app after a configuration change
const handleRestart = () => {
  // Perform any necessary cleanup or configuration here
  restart();
};

Example Use Case

You can use the restart functionality after a language change in your app:

const changeLanguage = (language) => {
  // Change app language or configuration
  i18n.changeLanguage(language);

  // Restart the app to apply the changes
  restart();
};

This will cause the app to reload and apply any new configurations, such as a language change, theme change, or other critical updates.


License

This project is licensed under the MIT License.