This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-05
Channels
- # announcements (1)
- # asami (25)
- # babashka (78)
- # beginners (24)
- # clojure (15)
- # clojure-europe (21)
- # clojure-losangeles (4)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (11)
- # cursive (17)
- # datomic (29)
- # events (1)
- # fulcro (4)
- # hyperfiddle (6)
- # jobs (1)
- # lsp (20)
- # malli (9)
- # off-topic (7)
- # pedestal (1)
- # polylith (2)
- # practicalli (1)
- # rdf (7)
- # reitit (1)
- # remote-jobs (1)
- # spacemacs (17)
- # specter (24)
- # vim (1)
is there a good example of how i can embed electric into a react site, I've tried using useEffect to load the main script after the target div#id has rendered but electric crashes stating that dom/node is nil. This is how im binding dom/node:
[dom/node (js/document.querySelector "#searchBar")]
Have a look a this https://github.com/hyperfiddle/electric-fiddle/blob/main/src/electric_tutorial/demo_reagent_interop.cljc.
I understand want to do the exact opposite. But the idea is symetric. You want a React component with a lifecyle. • allocate a dom node (e.g. a div) • start electric on componentDidMount • stop electric on componentWillUnmount
This is what our https://github.com/hyperfiddle/electric/blob/master/src/hyperfiddle/electric_fulcro_dom_adapter.cljc does. You’ll have to adapt it if you don’t use fulcro.
@U2DART3HA Thanks for the quick response, but let's say I want to put the bundled electric js code as a script tag in a Next.js app. Can I do this without wrapping the app and serving it together from a CLJS context? For example, can I add it as a script tag and do some steps onload from the vanilla js side of things?
Yes, it shouldn’t be an issue.