Last active
February 9, 2022 15:59
-
-
Save nikolasleblanc/d6f6e82050ebcf6a703bf33365c67785 to your computer and use it in GitHub Desktop.
DVC CRA Blocking Example
This file contains hidden or 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
import logo from './logo.svg'; | |
import './App.css'; | |
import { useDVCVariable } from '@devcycle/devcycle-react-sdk' | |
const variableKey = 'your variable name' | |
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 App |
This file contains hidden or 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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import './index.css'; | |
import App from './App'; | |
import reportWebVitals from './reportWebVitals'; | |
import { asyncWithDVCProvider } from '@devcycle/devcycle-react-sdk'; | |
(async () => { | |
const envKey = 'your env key' | |
const DVCProvider = await asyncWithDVCProvider({ envKey, user: { isAnonymous: true } }) | |
ReactDOM.render( | |
<DVCProvider> | |
<App /> | |
</DVCProvider>, | |
document.getElementById('root') | |
); | |
})() | |
// If you want to start measuring performance in your app, pass a function | |
// to log results (for example: reportWebVitals(console.log)) | |
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | |
reportWebVitals(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment