Last active
July 25, 2018 12:29
-
-
Save cristianoliveira/420598a45244ac974b5e0a7ac312d20c to your computer and use it in GitHub Desktop.
Example event use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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