Skip to content

Instantly share code, notes, and snippets.

@nikolasleblanc
Created February 8, 2022 22:38
Show Gist options
  • Save nikolasleblanc/33a2a1fa3942510dbd0424c86f997344 to your computer and use it in GitHub Desktop.
Save nikolasleblanc/33a2a1fa3942510dbd0424c86f997344 to your computer and use it in GitHub Desktop.
/*
1. Create a new project with create-react-app
2. yarn add @devcycle/devcycle-react-sdk
3. Replace src/App.js with the following
4. enter your envKey and variableKey
*/
import logo from './logo.svg';
import './App.css';
import { useDVCVariable, withDVCProvider } from '@devcycle/devcycle-react-sdk'
// change these
const envKey = 'envKey'
const variableKey = 'variableKey'
function App() {
const variable = useDVCVariable(variableKey, false)
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>{variable.value ? "Variable is true" : "Variable is false"}</p>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default withDVCProvider({
envKey,
user: { isAnonymous: true },
})(App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment