react-native-config | Bring some 12 factor love to your mobile apps | Form library
kandi X-RAY | react-native-config Summary
kandi X-RAY | react-native-config Summary
Bring some 12 factor love to your mobile apps!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-native-config
react-native-config Key Features
react-native-config Examples and Code Snippets
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh
import Secrets from 'react-native-config'
Secrets.API_URL // 'https://myapi.com'
Secrets.GOOGLE_MAPS_API_KEY // 'abcdefgh'
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh
import Secrets from 'react-native-config'
Secrets.API_URL // 'https://myapi.com'
Secrets.GOOGLE_MAPS_API_KEY // 'abcdefgh'
API_URL=https://myapi.com
GOOGLE_MAPS_API_KEY=abcdefgh
import Secrets from 'react-native-config'
Secrets.API_URL // 'https://myapi.com'
Secrets.GOOGLE_MAPS_API_KEY // 'abcdefgh'
yarn add react-native-config
react-native link react-native-config
// example, here I added the code inside onCreate() method of my MainApplication class
public void onCreate() {
String VAR_WITH_ANY_NAME = Buil
ENV_TYPE=Production
IS_ANIMATE=1
ENV_TYPE=Testing
IS_ANIMATE=0
import Config from 'react-native-config'
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
Ale
Community Discussions
Trending Discussions on react-native-config
QUESTION
It was working fine before I have done nothing, no packages update, no gradle update no nothing just created new build and this error occurs. but for some team members the error occur after gradle sync.
The issue is that build is generating successfully without any error but when opens the app it suddenly gets crash (in both debug and release mode)
Error
...ANSWER
Answered 2022-Feb-25 at 23:22We have fixed the issue by replacing
QUESTION
I'm creating a mobile app with TypeScript
, React Native
, and Storybook
.
A storybook code can import another component something like below without TS Error.
- Button.stories.tsx
ANSWER
Answered 2022-Jan-30 at 17:38Storybook mentions how to resolve this with typescript https://storybook.js.org/docs/react/configure/webpack#typescript-module-resolution
From their docs
QUESTION
I am getting the following error running React Native bundle release in the Android folder. I have tried updating Expo as well as installing an older version of it instead and I'm still getting the same error. Not sure what to try next?
...ANSWER
Answered 2022-Jan-04 at 05:28Just as we discussed in the comment section, I was able to resolve the issue by removing the react-native-reanimated package, as I was not using it. For the error you got after that, downgrading expo worked for me.
QUESTION
Here I am trying to get the environment details to fetch the base url of the application. Here is the package being used.
// configfile.ts
...ANSWER
Answered 2021-Nov-21 at 14:18Jest
For mocking the Config.ENV usage, create a folder __mocks__
at root of your project and create a file inside named react-native-config.js
inside the file paste below code
// react-native-config.js
QUESTION
I'm using react-native-config in my ReactNative app. After upgrading react-native-config to 1.4.5 and React Native to 0.66.1, everything worked well, but app name in iOS showing as __RN_CONFIG_DISPLAY_NAME.
Does anyone else have this problem?
...ANSWER
Answered 2021-Nov-06 at 09:52I changed __RN_CONFIG_DISPLAY_NAME to $(APP_DISPLAY_NAME) in info.plist and problem solved!
QUESTION
Error I'm getting Anytime I run npm test
:
ANSWER
Answered 2021-Jun-13 at 01:43[Solved] Work for me Install below
QUESTION
Okay, so Google is telling us "Background location access not declared" and not letting us publish our app. We have no use for background location, so we're trying to elimiate it completely.
Of course my manifest doesn't have it:
...ANSWER
Answered 2021-Mar-12 at 11:42I had this issue a few weeks ago, what a pain! In my case I had one dependency that was requiring background location without me noticing. Secondly, I had a wrong permission declaration on Google Play so my builds kept being rejected.
1. Find the evil dependencyTo do this I used the Merged Manifest inspector in Android Studio. This shows you what your manifest looks like after all project dependencies have been taken into account. Find ACCESS_BACKGROUND_LOCATION
and double click on it, this will bring you to the actual manifest where it's requested. Scroll to the top of this file and the package=some.package.name
should help you identify what it is. In my case the permission was requested by an old dependency I didn't use anymore so I just uninstalled it.
Note: if you're often working on different branches, make sure you have the correct dependencies installed and make a clean build before checking the merged manifest:
QUESTION
I need to build the same app to different applicationIds so that I can publish it on the Play Store / App Store as private applications for some of the customers of my company.
I decided to use react-native-config
, as it should allow me to change applicationId
and some env
variables easily.
I have created some .env.${variant}
files, that is, in the following examples, .env.customer1
.
I have set the needed buildTypes
as follows:
ANSWER
Answered 2021-Apr-21 at 14:02Thanks to this answer, I've succeeded in solving my issue.
Instead of using buildTypes
now I'm using flavors
.
So,
QUESTION
Just got this message from Apple this morning:
...ANSWER
Answered 2021-Mar-20 at 14:48You should double-check your Info.plist, You might have included something like this Privacy - Tracking Usage Description
QUESTION
Hello everyone, I need some help with multi environment in flutter.
Expected result:
- multi environments (like prod / dev / staging)
- easy for change and visually separated (it could be 3 diff or one file with good structure)
- variables could be used in native code
- support of Android Studio flutter run
- possible to run from Xcode
Quite easy, right? ) No!
What I have tried:
- flutter_dotenv - not support native code
- flutter_config - it was quite good, but to run flutter with env you should write
ENFILE=.env.dev flutter run ...
, so with this approach you loose advantages of Flutter run console in android studio and flutter app not rerun automatically --dart-define=
approach - long lines of run command, hard to read, hard to change, code repetition forflutter run
andflutter build
It looks like I have missed something, I have come from react-native ant all this question resolved by react-native-config
and command in package.json
but in flutter I don't see ways for predefined command like in package json (only Run/Debug Configurations
). But flutter run don't support env files but just sh scripts possible run with ENFILE but they don't trigger the flutter run console.
I will be grateful for your help ))
...ANSWER
Answered 2021-Mar-10 at 21:57yes, you did miss something past flutter 1.17 you can use compile-time vars ie via ---dart-define=
flutter run --dart-define=SOME_VAR=SOME_VALUE --dart-define=OTHER_VAR=OTHER_VALUE
class EnvironmentConfig { static const SOME_VAR = String.fromEnvironment('SOME_VAR'); static const OTHER_VAR = String.fromEnvironment('OTHER_VAR'); }
Note that anything with URLs in it is different from android vs ios and you have more hoop on ios to get it to turn outright.
follow up refs are:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-config
Manual Link (iOS) In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-config and add ReactNativeConfig.xcodeproj Expand the ReactNativeConfig.xcodeproj ➜ Products folder In the project navigator, select your project. Add libReactNativeConfig.a to your project's Build Phases ➜ Link Binary With Libraries And go the Build Settings tab. Make sure All is toggled on (instead of Basic) Look for Header Search Paths and add $(SRCROOT)/../node_modules/react-native-config/ios/** as non-recursive
Manual Link (Android) android/settings.gradle + include ':react-native-config' + project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') android/app/build.gradle dependencies { implementation "com.facebook.react:react-native:+" // From node_modules + implementation project(':react-native-config') } MainApplication.java + import com.lugg.ReactNativeConfig.ReactNativeConfigPackage; @Override protected List<ReactPackage> getPackages() { return Arrays.asList( new MainReactPackage() + new ReactNativeConfigPackage() ); }
Manual Link (Windows) windows/myapp.sln Add the RNCConfig project to your solution. Open the solution in Visual Studio 2019 Right-click Solution icon in Solution Explorer > Add > Existing Project if using react-native-windows@0.62 or later select node_modules\react-native-config\windows\RNCConfig\RNCConfig.vcxproj if using react-native-windows@0.61 select node_modules\react-native-config\windows\RNCConfig61\RNCConfig61.vcxproj windows/myapp/myapp.vcxproj Add a reference to RNCConfig to your main application project. From Visual Studio 2019: Right-click main application project > Add > Reference... Check RNCConfig from Solution Projects. pch.h Add #include "winrt/RNCConfig.h". app.cpp Add PackageProviders().Append(winrt::RNCConfig::ReactPackageProvider()); before InitializeComponent();.
With one extra step environment values can be exposed to "Info.plist" and Build settings in the native project. Add dependency to react-native-config.
click on the file tree and create new file of type XCConfig
save it under ios folder as "Config.xcconfig" with the following content:
add the following to your ".gitignore":
go to project settings
apply config to your configurations
Go to Edit scheme... -> Build -> Pre-actions, click + and select New Run Script Action. Paste below code which will generate "tmp.xcconfig" before each build exposing values to Build Settings and Info.plist. Make sure to select your target under Provide build settings from, so $SRCROOT environment variables is available to the script. (Note that this snippet has to be placed after "cp ... ${PROJECT_DIR}/../.env" if approach explained below is used). "${SRCROOT}/../node_modules/react-native-config/ios/ReactNativeConfig/BuildXCConfig.rb" "${SRCROOT}/.." "${SRCROOT}/tmp.xcconfig"
You can now access your env variables in the Info.plist, for example $(MY_ENV_VARIABLE). If you face issues accessing variables, please open a new issue and provide as much details as possible so above steps can be improved.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page