Skip to content

Instantly share code, notes, and snippets.

@asaschachar
Last active September 10, 2019 18:56
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 asaschachar/6ce15a9e018d4cfde05e1eba24199bd0 to your computer and use it in GitHub Desktop.
Save asaschachar/6ce15a9e018d4cfde05e1eba24199bd0 to your computer and use it in GitHub Desktop.
import React from 'react';
import {
createInstance,
OptimizelyProvider,
OptimizelyFeature,
} from '@optimizely/react-sdk'
const optimizely = createInstance({
sdkKey: '<Your_SDK_Key>',
})
class App extends React.Component {
render() {
return (
<OptimizelyProvider
optimizely={optimizely}
user={{
id: 'user123',
attributes: {
'customerId': 123,
'isVip': true,
}
}}>
<h1>Example Application</h1>
<div>
<OptimizelyFeature feature="hello_world">
{(isEnabled) => (
isEnabled
? (<p> You got the <strong>hello_world</strong> feature! </p>)
: (<p> You did not get the feature </p>)
)}
</OptimizelyFeature>
</div>
</OptimizelyProvider>
)
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment