React helpers for Google Optimize A/B testing.
npm install react-google-optimizeHelpers for Google Optimize A/B testing.
```
npm i react-google-optimize
You must have Google Optimize added to your application.
`
import React from 'react';
import { Experiment, Variant } from 'react-google-optimize';
export default class App extends React.Component {
render() {
return(
Default variant
Variant 1
Variant 2
)
}
}
``
Props:
- name: the experiment name configured in Google Optimize.
- loadingComponent: a component to be rendered while the variants are being requested from Google Optimize.
Props:
- default: sets this variant as the default. This value is used in case Google Optimize is not loaded or something fails.
- id: the variant id configured in Google Optimize.