Skip to content

Instantly share code, notes, and snippets.

View naishe's full-sized avatar
🚀
Let's Launch This Thing!

Nishant Neeraj naishe

🚀
Let's Launch This Thing!
View GitHub Profile
@naishe
naishe / index.js.diff
Created August 2, 2020 03:45
Integrating CodePush 6
import {AppRegistry} from 'react-native';
- import App from './App';
+ import AppWrappedInCodePush from './AppWrappedInCodePush';
import {name as appName} from './app.json';
- AppRegistry.registerComponent(appName, () => App);
+ AppRegistry.registerComponent(appName, () => AppWrappedInCodePush);
@naishe
naishe / settings.gradle.diff
Created August 2, 2020 03:43
Integrating CodePush 5
// android/settings.gradle
rootProject.name = 'myapp'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
- include ':app'
+ include ':app', ':react-native-code-push'
+ project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
@naishe
naishe / strings.xml.diff
Created August 2, 2020 03:40
Integrating CodePush 4
<!-- android/app/src/main/res/values/strings.xml -->
<resources>
<string name="app_name">myapp</string>
+ <string moduleConfig="true" name="CodePushDeploymentKey">Jbach1Qk_achQarrrhNOA9zwVlJnruLsa9jsr</string>
</resources>
@naishe
naishe / MainApplication.java.diff
Created August 2, 2020 03:36
Integrating CodePush 3
// File: android/app/src/main/java/com/myapp/MainApplication.java
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
+ import com.microsoft.codepush.react.CodePush; // 1. CodePush
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
@naishe
naishe / build.gradle.diff
Created August 2, 2020 03:32
Integrating CodePush 2
// file: android/app/build.gradle
apply from: "../../node_modules/react-native/react.gradle"
+ apply from: "../../node_modules/react-native-code-push/android/codepush.gradle" // CodePush
@naishe
naishe / AppWrappedInCodePush.tsx
Created August 2, 2020 03:27
Integrating with CodePush 1
import React, {Component} from 'react';
import App from './App';
import codePush from 'react-native-code-push';
class AppWrappedInCodePush extends Component {
render() {
return <App />;
}
}
@naishe
naishe / i18next-custom-format-partial.ts
Created July 21, 2020 15:18
i18next custom formatting function
interpolation: {
escapeValue: false,
format: function (value: any, format?: string, lng?: string) {
switch (format) {
case 'flags':
if (
typeof value !== 'number' ||
value < 1 ||
!Number.isInteger(value)
@naishe
naishe / LanguageSelector.tsx
Created July 21, 2020 12:57
React Native component to show and change i18next language options
import React from 'react';
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Dimensions,
} from 'react-native';
import {useTranslation} from 'react-i18next';
@naishe
naishe / i18nextConf.ts
Created July 21, 2020 12:36
Configuring i18next for React Native
import i18n, {
LanguageDetectorAsyncModule,
Services,
InitOptions,
} from 'i18next';
import {initReactI18next} from 'react-i18next';
import AsyncStorage from '@react-native-community/async-storage';
import * as RNLocalize from 'react-native-localize';
import en from './en';
import hi from './hi';
@naishe
naishe / common.ts
Last active July 21, 2020 11:48
i18next file organization
export default {
ok: 'OK',
cancel: 'Cancel',
};