Last active
March 8, 2022 14:33
-
-
Save onosendi/64f52fc70943dfdea336e01d0b4d4765 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Foo</title> | |
</head> | |
<body> | |
<div id="root" data-foo="{"foo": "bar"}"></div> | |
</body> | |
</html> |
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
const rootEl = document.getElementById('root'); | |
let foo; | |
try { | |
foo = JSON.parse(rootEl.dataset.foo); | |
} catch (error) { | |
console.error(error); | |
} | |
function App({ foo }) { | |
console.log(foo); | |
return null; | |
} | |
ReactDOM.render(<App foo={foo} />, rootEl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment