reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
rberger 2021-04-14T03:15:26.104700Z

Is there a “reagent way” to insert meta tags in the <head> of the dom the application is running in? I’ve figured out a way to do it with javascript interop and directly manipulating the dom, but wondering if there is a more reagent way to do it that could be fed with data from re-frame or r/atoms

valtteri 2021-04-14T04:40:46.107400Z

Re-frame effects are meant for this kind of things.

valtteri 2021-04-14T04:43:04.110200Z

Basically it’s just a bit more controlled way to do what you already do with interop and you get to pick data from app-db or any other coeffects

rberger 2021-04-14T04:45:10.110400Z

The re-frame is one part, but the other part was wondering if there is a more reagent way to append / update / insert into the <head> The only think I found was to render into head but that seemed to replace the whole head not add to it.

rberger 2021-04-14T04:49:20.110600Z

I tried to use https://github.com/nfl/react-helmet with Reagent, but I couldn’t get it to work. It wasn’t clear how to get it to fit into the Reagent way of starting the app.

valtteri 2021-04-14T04:55:29.113700Z

Head is usually “outside” the react render tree. Imo using dom manipulation side-effect would be idiomatic :thinking_face:

valtteri 2021-04-14T04:56:48.115500Z

I mean, to me it would be more weird if reagent did side-effects outside its render tree

rberger 2021-04-14T05:05:13.116Z

Yeah, I need to be able to dynamically create meta tags to support https://support.shareaholic.com/hc/en-us/articles/115005177166-Adding-Meta-Tags-using-JavaScripthttps://ogp.me/. Some of the data in the tag isn’t known until the page is being loaded.

rberger 2021-04-14T05:12:10.116300Z

But thanks for the reminder that I should probably do the interop in an effect. That will solve one problem I’m having

1👍
NoahTheDuke 2021-04-14T20:48:30.117300Z

I read this 2017 post about reagent speed https://yogthos.net/posts/2017-03-26-ReagentReactView.html and I realized that I don't quite understand how cursors work

NoahTheDuke 2021-04-14T20:49:52.118400Z

in the example that @yogthos writes, a given cursor is created within for loops:

(for [idx (range (count (:players @game)))]
     ^{:key idx}
     [player-component (reagent/cursor game [:players idx])])

NoahTheDuke 2021-04-14T20:50:29.119Z

doesn't that re-create the cursor every time the enclosing function is called?