Skip to content

Instantly share code, notes, and snippets.

@felher
Created June 17, 2024 14:07
Show Gist options
  • Save felher/647ed24eb392877a05f049cae206ca75 to your computer and use it in GitHub Desktop.
Save felher/647ed24eb392877a05f049cae206ca75 to your computer and use it in GitHub Desktop.
Create a react-icons icon from javascript only with no build tool
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="module">
import React from "https://esm.sh/react@18/"
import ReactDOMClient from "https://esm.sh/react-dom@18/client"
import * as ReactIconsFa from "https://esm.sh/react-icons@5.2.1/fa"
window.React = React
window.ReactDOM = ReactDOMClient
window.ReactIconsFa = ReactIconsFa
window.onReactStuffLoaded();
</script>
</head>
<body>
<div id="anchor"></div>
<script>
window.onReactStuffLoaded = () => {
const anchor = document.getElementById("anchor")
const root = window.ReactDOM.createRoot(anchor)
root.render(window.React.createElement(window.ReactIconsFa.FaBeer))
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment