WebReflection / neverland

React like Hooks for lighterhtml
https://medium.com/@WebReflection/neverland-the-hyperhtmls-hook-a0c3e11324bb
ISC License
244 stars 7 forks source link

useRef, removal of define and other library changes #8

Closed yuretz closed 5 years ago

yuretz commented 5 years ago

First of all, I would like to say that I like this library very much. It puts the good old ideas behind hyperHTML into a new, shiny, more functional-like prospective. Really cool work, thank you for sharing it!

However, there were a few changes to the library lately, and I don't quite understand the motivation behind the changes, so I thought I could ask my questions here.

The useRef() functionality provided with the library doesn't seem to support declarative references to the rendered DOM nodes via a special ref attribute the way React does it out of the box (or maybe I just haven't found a proper way to do it). A workaround that worked with the older version of neverland was using define() attribute intent. But define() support was removed in the newest version of the library. Why? From my experience with hyperHTML, I find intents feature quite useful in various scenarios to plug some custom stuff into the rendering process.

Another difference that I've noticed with the latest version is that I am no longer able to append multiple component instances of component to the same parent element with appendChild(). The last one always replaces all the previous ones. You can see the example here. Is it the intended behavior?

WebReflection commented 5 years ago

I don't quite understand the motivation behind the changes

I wanted to use lighterhtml and dom-augmentor instead of hyperHTML since hyperHTML with hooks is kinda overkill, compared to lighterhtml

The useRef() functionality provided with the library doesn't seem to support declarative references to the rendered DOM nodes via a special ref attribute the way React does

It does now 😉

But define() support was removed in the newest version of the library. Why?

I never liked intents much. You can pass just a function in any node and that'd be invoked on each render. Or, actually, I am thinking about enabling a special onrender or onupdate attribute that will be invoked each time, if specified.

However, with hooks intents become less useful, 'cause any "magic" behavior can be added on top via hooks.

I might reconsider intents in lighterhtml but being lighterhtml a fresh start I don't want to rush anything right now.

I am no longer able to append multiple component instances of component to the same parent element with appendChild().

Yup, that was a bug. Fixed now 👋

yuretz commented 5 years ago

Thanks a lot for your explanations and the fix! Things are much clearer in my head now and your point about intents makes a lot of sense, indeed.

I'm actually looking forward to a possibility to try and see if neverland could help completing my realworld tasks and projects :smile: