
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@harnessio/ff-react-native-client-sdk
Advanced tools
React Native SDK For Harness Feature Flags ========================
Intro
Requirements
Quickstart
Further Reading
Build Instructions
Use this README to get started with our Feature Flags (FF) SDK for React Native. This guide outlines the basics of getting started with the SDK and provides a full code sample for you to try out. This sample doesn’t include configuration options, for in depth steps and configuring the SDK, for example, disabling streaming or using our Relay Proxy, see the React Native SDK Reference.
For a sample FF React Native SDK project, see our test test React Native project.
React 16 or newer
React Native 0.63 or newer
To follow along with our test code sample, make sure you’ve:
Install the React Native SDK by adding it to your project's package.json
file:
"@harnessio/ff-react-native-client-sdk": "^1.0.2"
Or install using npm:
$ npm install --save @harnessio/ff-react-native-client-sdk
For iOS, run the following commands from project root folder
$ cd ios
$ pod install
The following is a complete code example with a fresh React-Native project that you can use to test the harnessappdemodarkmode
Flag you created on the Harness Platform. When you run the code it will:
Install expo.
npm install -g expo-cli
Using Expo, initialize a project. For the best experience, select Minimal
as the template when prompted.
expo init SampleProject
cd SampleProject
Add the Harness React Native SDK to the package.json
under the dependencies
section.
"@harnessio/ff-react-native-client-sdk": "^1.0.2"
Replace the code in App.js
with the following Sample Code, and replace apiKey
with your Client SDK Key.
import cfClientInstance, {CfConfiguration, CfTarget} from '@harnessio/ff-react-native-client-sdk';
export default function App() {
const flagName = 'harnessappdemodarkmode';
const [client, setClient] = useState(null);
const [flagValue, setFlagValue] = useState(null);
async function initializeClient() {
let cfClient = cfClientInstance;
let cfConfig = new CfConfiguration();
cfConfig.streamEnabled = true;
const cfTarget = new CfTarget();
cfTarget.identifier = 'Harness RN Sample App'
const apiKey = "your-client-sdk-key";
try {
await cfClientInstance.initialize(apiKey, cfConfig, cfTarget);
} catch (err) {
console.log(err);
}
setClient(cfClient);
}
async function evalFlag() {
let res = await client.boolVariation(flagName, false);
setFlagValue(res.value);
}
useEffect(() => {
if (client == null) {
initializeClient();
} else {
evalFlag();
}
});
return (
<View style={styles.container}>
<Text>
Feature flag '{flagName}' is {JSON.stringify(flagValue)}
</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Start your desired simulator, either Android or iOS and run
yarn run ios
or
expo run:ios
Replace ios
above with android
if running on an Android simulator.
For further examples and config options, see the React Native SDK Reference.
For more information about Feature Flags, see our Feature Flags documentation.
Harness is a feature management platform that helps teams to build better software and to test features quicker.
FAQs
[![React version][react-badge]][reactjs] [![React Native version][react-native-badge]][reactnative] [![TypeScript version][ts-badge]][typescript-4-7] [![Node.js version][nodejs-badge]][nodejs] [![APLv2][license-badge]][license]
We found that @harnessio/ff-react-native-client-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.