I am looking at this React example of how material.io component is implemented/integrated with React component:
I wonder how one would go about doing same with hyperHTML since there are no lifecycle event calls within hyper.Component
like componentDidMount
or componentWillUnmount
.
It was said that I can do that after render
call but that is typically called from outside of component.
sorry I've seen this only now.
I'd like to clarify a couple of things:
If you try latest version, or let's say 1.10+, you will have the ability to define
onconnected(evt) { ... }
andondisconnected(evt) { ... }
methods in each of yourhyper.Component
class definition.It's a fairly recent feature, unfortunately not documented yet. but it provides all you need to behave like Custom Elements
connectedCallback
anddisconnectedCallback
methods (and remember, there is also an HyperHTMLElement project to create real custom elements).The following is a basic example:
I hope this would give you enough power to replicate the material example.
The other part I'd like to clarify:
That's not entirely correct. Yes, the
component.render()
is called automatically, if needed, but what matters is what you return.I am using the same code I've used for the previous
Clock
example:as you can see, you can always interact with the rendered node. After all, all hyperHTML does, is creating the content you write, nothing more, nothing less.
I hope these clarifications would help you to move forward. Here, eventually, to answer other questions.