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?keys are not encapsulated within components
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?
besides a simple wrapping component that is
(defn wrapper [changing-thing]
^{:key changing-thing} [form-3-component changing-thing])
React components don't have control over when they mount/unmount
good point
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
it would be interesting if components could unmount themselves, but it's not possible with react today AFAIK
Yeah, I think you’re right… things work well with the component as is so I reckon I’ll just use the wrapper. Thanks!
How do you test reagent view functions. I tried looking online didnt find any good resources
@jpsoares106 just tried devcards. And I have to say I am very impressed!
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)
I test it visually with devcards https://github.com/bhauman/devcards
Also online articles that can inspire you https://juxt.pro/blog/posts/cljs-apps.html https://medium.com/adstage-engineering/how-we-test-our-full-stack-clojure-app-b18d79ee9e00