Skip to content

Latest commit

 

History

History

ReactNativeApp

FeatBit React Native SDK example

This project is an example of how to use the featbit-react-native-sdk. It is built based on the project bootstrapped using @react-native-community/cli.

This example asumes you have a FeatBit environment created which has the following sdkKey

Obg68EqYZk27JTxphPgy7At1aJ8GaAtEaIA1fb3IpuEA.

This environment has the following flags:

{
    "id": "robot",
    "variation": "AlphaGo",
    // variation data type, string will be used if not specified
    variationType: VariationDataType.string
},

Getting Started

Note: Make sure you have completed the React Native - Environment Setup instructions till "Creating a new application" step, before proceeding.

Step 1: Start the Metro Server

First, you will need to start Metro, the JavaScript bundler that ships with React Native.

To start Metro, run the following command from the root of your React Native project:

   // In the root folder of the repo
   npm install && npm run build
   
   // In the examples/ExpoApp folder
   npm install
   
   // In the root folder of the repo
   npm link ./examples/ExpoApp/node_modules/react

Step 2: Start your Application

Let Metro Bundler run in its own terminal. Open a new terminal from the root of your React Native project. Run the following command to start your Android or iOS app:

# using npm
npm run start

// Then follow the instructions in the terminal to run the app in an emulator or on a physical device.

If everything is set up correctly, you should see your new app running in your Android Emulator or iOS Simulator shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

Troubleshooting

Error: Hooks can only be called inside the body of a function component.

if see error: Hooks can only be called inside the body of a function component. just run the following command in the root folder of the repo.

npm link ./examples/ReactNativeApp/node_modules/react