Fork me on GitHub
#hyperfiddle
<
2024-02-05
>
Dennis Orsini03:02:57

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")]

Geoffrey Gaillard08:02:51

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

Dennis Orsini23:02:23

@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?

Geoffrey Gaillard10:02:39

Yes, it shouldn’t be an issue.