Skip to content

Instantly share code, notes, and snippets.

@cristianoliveira
Last active July 25, 2018 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianoliveira/420598a45244ac974b5e0a7ac312d20c to your computer and use it in GitHub Desktop.
Save cristianoliveira/420598a45244ac974b5e0a7ac312d20c to your computer and use it in GitHub Desktop.
Example event use
// Use case
// Render things based on the experiment variant
class FooTest extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string
};
constructor(props) {
super(props);
}
componentDidMount() {
optimizelyReady.then(() => {
const variant = optimizely.getExperiment();
this.setState({ experimentVariant: variant });
});
}
render() {
if (this.state.experimentVariant === 'x') {
return <ComponentA />;
}
return <ComponentB >;
}
}
export default FooTest;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment