Fork me on GitHub

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!

Vishal Gautam17:04:57

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

Vishal Gautam18:04:28

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


Cljs podcast episode about Reagent is out! (this was recorded half a year ago so it doesn't go into detail of the latest changes, but Hooks are mentioned)

👂 8
parrot 16
👍 8