Last active
April 28, 2024 17:21
-
-
Save fmaylinch/298018ad34503e15fc2c1ebd6fba7cf9 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
// This code is displays a counter above. | |
// The code is transpiled with Babel and run with eval(). | |
const { useState } = React; // imports don't work here | |
function Counter() { | |
const [count, setCount] = useState(0); | |
return ( | |
<div style={{margin: 20}}> | |
<button onClick={() => setCount(count + 1)} | |
style={{padding: 10}}> | |
Just a button clicked {count} times | |
</button> | |
<LinkToArkhamHorrorTracker/> | |
</div> | |
); | |
} | |
// And just for fun... a tracker for Akkham Horror LGC | |
const arkhamHorrorTrackerGist = "https://gist.githubusercontent.com/fmaylinch/f888755668ad83a869926ab1aefb42c0/raw"; | |
const arkhamHorrorTrackerUrl = `/?runCode=true&fetchCode=${arkhamHorrorTrackerGist}`; | |
function LinkToArkhamHorrorTracker() { | |
return ( | |
<div style={{padding: 10}}> | |
<a href={arkhamHorrorTrackerUrl}>🦑 Arkham Horror LGC tracker 🦑</a> | |
</div> | |
) | |
} | |
window.scroll({top: 0, behavior: 'smooth'}); | |
reactRoot.render(<Counter />); // reactRoot is mounted on the #main DOM element |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment