Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-native-ab-fixed
Advanced tools
A component for rendering A/B tests in React Native (updated from react-native-ab)
A component for rendering A/B tests in React Native.
npm install react-native-ab@latest --save
Once you've got your A/B tests set up, you'll need a place to send the data. Check out these libraries for A/B testing:
All you need is to require
the react-native-ab
module and then use the provided tags (<Experiment>
, and <Variant>
).
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
TouchableHighlight
} = React;
var { Experiment, Variant } = require('react-native-ab');
var rnabtest = React.createClass({
render: function() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={this._resetExperiment}>
<View>
<Experiment
ref="welcomeExperiment"
name="welcome-message"
onChoice={(test, variant) => console.log(test, variant)}
>
<Variant name="standard">
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</Variant>
<Variant name="friendly">
<Text style={styles.welcome}>
Hey there! Welcome to React Native!
</Text>
</Variant>
<Variant name="western">
<Text style={styles.welcome}>
Howdy, partner! This here is React Native!
</Text>
</Variant>
</Experiment>
</View>
</TouchableHighlight>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+Control+Z for dev menu
</Text>
</View>
);
},
_resetExperiment() {
this.refs.welcomeExperiment.reset();
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('rnabtest', () => rnabtest);
<Experiment>
Propertiesname
The name of your experiment, for example "welcome-message"
.
choose
Example callback signature: function(variants)
Must return an instance of Variant
A function which should use a randomization algorithm to pick one of your variants. Defaults to a random selection using Math.random()
onChoice
Example callback signature: function(experimentName, variantName)
Called when a Variant
has been chosen for your Experiment
.
onRawChoice
Example callback signature: function(experiment, variant)
Same as onChoice
, but the objects passed are React component instances.
<Experiment>
methodsYou can access component methods by adding a ref
(ie. ref="welcomeExperiment"
) prop to your <Experiment>
element, then you can use this.refs.welcomeExperiment.reset()
, etc. inside your component.
reset()
Resets the experiment. The next time the experiment is rendered, a new variant may be chosen.
getActiveVariant()
Returns the currently displayed Variant
.
getVariant(variantName)
Returns the instance of the specified Variant
name.
<Variant>
Propertiesname
The name of your variant, for example "western"
.
Only the Variant
tag element exist within the Experiment
element. Variant
tags can contain only one root element.
FAQs
A component for rendering A/B tests in React Native (updated from react-native-ab)
We found that react-native-ab-fixed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.