- Sharing what has worked for me in different React Native projects
- Reusing screens in different parts of your app
- Easy to work separately in a feature
- Add an extra level (nested folder) only when necessary
- Don't overuse
index.js
for everything
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fetch from 'node-fetch'; | |
import AdmZip from 'adm-zip'; | |
import zlib from 'zlib'; | |
import fs from 'fs'; | |
import path from 'path'; | |
const username = ''; // Add secret username | |
const password = ''; // Add secret password | |
const authHeader = `Basic ${Buffer.from(`${username}:${password}`).toString('base64')}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// styles.xml | |
<resources> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimaryDark">@color/primaryDark</item> | |
<item name="android:windowBackground">@color/background</item> | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// splash_screen.xml | |
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" | |
android:opacity="opaque"> | |
<item android:drawable="@color/darkBackground" /> | |
<item | |
android:gravity="center" | |
android:bottom="72dp"> | |
<bitmap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// styles.xml | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | |
<item name="colorPrimaryDark">@color/primaryDark</item> | |
<item name="android:windowBackground">@color/background</item> | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNSplashScreenModule.java | |
import android.app.Activity; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
import javax.annotation.Nonnull; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainActivity.java | |
public void switchToReactView() { | |
if (mReactRootView != null && !mReactRootView.isAttachedToWindow()) { | |
mReactRootView.setAlpha(0f); | |
mReactRootView.animate() | |
.alpha(1f) | |
.setInterpolator(new AccelerateDecelerateInterpolator()) | |
.setDuration(350) | |
.setListener(new Animator.AnimatorListener() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainActivity.java | |
@Override | |
protected ReactActivityDelegate createReactActivityDelegate() { | |
return new ReactActivityDelegate(this, getMainComponentName()) { | |
@Override | |
protected ReactRootView createRootView() { | |
return new RNGestureHandlerEnabledRootView(MainActivity.this); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String currentLocale; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
MainActivity.currentLocale = getResources().getConfiguration().locale.toString(); | |
} | |
@Override | |
public void onConfigurationChanged(Configuration newConfig) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const EnhanceDropdown = ComposedComponent => class extends Component { | |
constructor() { | |
super(); | |
this.state = { isOpen: false }; | |
this.onToggle = this.onToggle.bind(this); | |
this.handleDocumentClick = this.handleDocumentClick.bind(this); | |
this.onSelect = this.onSelect.bind(this); | |
} | |
componentDidMount() { | |
window.addEventListener('click', this.handleDocumentClick) |
NewerOlder