reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
donavan 2020-04-29T14:51:06.317700Z

Is there a way to easily add the :key metadata to form-3 components. I need to completely recreate a form-3 component which I can do by…

[:div ^{:key changing-thing} [form-3-component changing-thing]]
…but I’d prefer it if it were encapsulated within the component. Or is there another way of doing this that I’m not thinking about?

lilactown 2020-04-29T14:57:11.318Z

keys are not encapsulated within components

donavan 2020-04-29T14:58:23.319800Z

ok, that makes sense, I know it’s react that is recreating the component from scratch when the key changes… is there another way of achieving a complete component recreation?

donavan 2020-04-29T14:59:10.320600Z

besides a simple wrapping component that is

donavan 2020-04-29T14:59:57.321900Z

(defn wrapper [changing-thing]
  ^{:key changing-thing} [form-3-component changing-thing])

lilactown 2020-04-29T15:00:11.322200Z

React components don't have control over when they mount/unmount

donavan 2020-04-29T15:01:27.323100Z

good point

lilactown 2020-04-29T15:01:32.323300Z

you can have the key be part of the usage of the component, use the wrapper method, or refactor the component so that it doesn't rely on component instantiation when props change

lilactown 2020-04-29T15:02:12.324100Z

it would be interesting if components could unmount themselves, but it's not possible with react today AFAIK

donavan 2020-04-29T15:02:35.324600Z

Yeah, I think you’re right… things work well with the component as is so I reckon I’ll just use the wrapper. Thanks!

v 2020-04-29T17:03:57.326300Z

How do you test reagent view functions. I tried looking online didnt find any good resources

v 2020-04-30T18:42:28.332Z

@jpsoares106 just tried devcards. And I have to say I am very impressed!

juhoteperi 2020-04-29T19:03:49.327300Z

Cljs podcast episode about Reagent is out! https://soundcloud.com/user-959992602/s4-e2-reagent-with-juho-teperi (this was recorded half a year ago so it doesn't go into detail of the latest changes, but Hooks are mentioned)

2👍2👂4🦜
Jp Soares 2020-04-29T19:06:06.327500Z

I test it visually with devcards https://github.com/bhauman/devcards