I have summarized and compiled a list of React.JS best practices from various sources across the internet.
yarn add react-native-config
react-native link react-native-config
- Create
.env
files for each configuration. Ex:.env.dev
,.env.prod
, etc Ex:
API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
This file contains 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
Below is a full tutorial on how to setup and use Googles Firebase push notification API for both Android and iOS. It is based on this | |
earlier implementation of Googles GCM method: https://gist.github.com/prime31/5675017 - FCM is the new method and GCM will eventually be | |
retired. | |
## THE BELOW METHOD IS THE NEWER FCM METHOD: | |
Register your app in the FCM Console: https://console.firebase.google.com (add project) | |
1. Click on the newly added project, in the upper left menu is the "Overview" and Gear Settings. | |
2. Click on the GEAR settings icon, and then on "Project Settings" | |
3. In the main screen, click on "Cloud Messaging" |
Method | Side effects1 | State updates2 | Example uses |
---|---|---|---|
Mounting | |||
componentWillMount |
✓ | Constructor equivalent for createClass |
|
render |
Create and return element(s) | ||
componentDidMount |
✓ | ✓ | DOM manipulations, network requests, etc. |
Updating | |||
componentWillReceiveProps |
✓ | Update state based on changed props |
This file contains 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
{ fontWeight: '100' }, // Thin | |
{ fontWeight: '200' }, // Ultra Light | |
{ fontWeight: '300' }, // Light | |
{ fontWeight: '400' }, // Regular | |
{ fontWeight: '500' }, // Medium | |
{ fontWeight: '600' }, // Semibold | |
{ fontWeight: '700' }, // Bold | |
{ fontWeight: '800' }, // Heavy | |
{ fontWeight: '900' }, // Black |
This file contains 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
/** | |
* Utility class to read encrypted PEM files and generate a | |
* SSL Socket Factory based on the provided certificates. | |
* The original code is by Sharon Asher (link below). I have modified | |
* it to use a newer version of the BouncyCastle Library (v1.52) | |
* | |
* Reference - https://gist.github.com/sharonbn/4104301" | |
*/ | |
import org.bouncycastle.cert.X509CertificateHolder; |
This file contains 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
// Dagger 1 example | |
@Module( | |
complete = false, | |
library = true | |
) | |
public final class ApiModule { | |
@Provides | |
@Singleton | |
Retrofit provideRetrofit(Gson gson, Application app) { | |
return new Retrofit.Builder() |
This file contains 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
/** | |
* Copyright 2012 Benjamin Fagin | |
* http://www.unquietcode.com | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to |