Skip to content

Instantly share code, notes, and snippets.

@msahu2595
Forked from moraj-gloitel/index.js
Created April 28, 2025 13:53
Show Gist options
  • Save msahu2595/4e30c33b17fd239d8b55271165586707 to your computer and use it in GitHub Desktop.
Save msahu2595/4e30c33b17fd239d8b55271165586707 to your computer and use it in GitHub Desktop.
Initial Setup (React Native)
/**
* @format
*/
import React from 'react';
import {AppRegistry, Text, TextInput} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
// This is done to ensure that the text size remains consistent across all devices.
if (Text.defaultProps) {
Text.defaultProps.allowFontScaling = false;
} else {
Text.defaultProps = {};
Text.defaultProps.allowFontScaling = false;
}
if (TextInput.defaultProps) {
TextInput.defaultProps.allowFontScaling = false;
} else {
TextInput.defaultProps = {};
TextInput.defaultProps.allowFontScaling = false;
}
// Check if app was launched in the background and conditionally render null if so
function HeadlessCheck({isHeadless}) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
return null;
}
// Render the app component on foreground launch
return <App />;
}
AppRegistry.registerComponent(appName, () => HeadlessCheck);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment