This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-24
Channels
Hi! how can i get/swap the implementation of a particular lifecycle method of a reagent component?
I’m trying to implement a function named « resizable » that takes a callback (to call on resize event) and a component (hiccup vector) and add the event initialization to the component-did-mount method of the given component
@pbaille: I’m not sure what you’re trying to achieve. Is it possible to listen to component-will-receive-props
and unbind and rebind the on-resize event when the callback changes?
I know that I could in each component definition, add it manually but I would like an abstraction if possible
in a more abstract way, I would like to be able to compose lifecycle methods of an existing component
What’s your use case?
I see, but its mainly syntactic sugar on top of defining reagent/create-class
, isn’t it?
When you define the lifecycle methods as standalone functions, you can easily call comp
on them.
if there is a way to access/set component lifecycle methods of an already defined component it should be possible to do what I want
You’ll probably know this, but could call with-meta
on the component, I’m not sure that works at runtime.
Don’t know how to do it otherwise. I’m not 100% sure what the usecase could be, I’ve been using React the last 2 years and never needed anything like this.
ok maybe it is useless, but what get me on this way is the way that the « rum » library works, do you know it?
Rum doesn’t allow this either, does it? You component definition all happens at compile time (just like with-meta
) in a macro.
If I’ve understood well , rum introduce the idea of mixins that allow that kind of lifecycle-methods composition
But that all happens at compile time. It isn’t any different than Reagent allows you to do. Or I’m missing a big insight in how Rum works . Do you have a link where this behavior of rum is explained?