babashka / scittle

Execute Clojure(Script) directly from browser script tags via SCI
https://babashka.org/scittle
Eclipse Public License 1.0
326 stars 30 forks source link

how to require javascript library #83

Closed schneiderlin closed 2 months ago

schneiderlin commented 2 months ago

for reagent hook, I need to require ["react" :as react]. how to do that in scittle?

borkdude commented 2 months ago

In scittle you include react in a script tag:

<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>

This makes react available as a global: js/React, I believe. So you don't need to do this via require.