Closed tkh44 closed 7 years ago
This is really cool! - whatever is most native to preact
is ideal I think; don't think using createClass
is desirable then (not even sure that's the best idea for react
now haha - is it?)
Also I wonder: would it be better to use prototype methods? I know it's quite common in the preact / react world but it might save some compilation if we use prototypes. Some quick googling makes it seem we can replace:
class Clx extends preact.Component {}
with:
function Clx () {}
Clx.prototype = Object.create(preact.Component)
Clx.prototype.constructor = preact.Component
What do you think?
That was what I was going to suggest. I did a quick test here (See Demo component) and it works fine. I wasn't sure if preact was doing any special tricks.
cool! :D
On Mon, Jan 30, 2017 at 3:20 PM Kye Hohenberger notifications@github.com wrote:
That was what I was going to suggest. I did a quick test here (See Demo component) http://codepen.io/tkh44/pen/oBpVqd?editors=0010#0 and it works fine. I wasn't sure if preact was doing any special tricks.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/yoshuawuyts/nanocomponent-adapters/pull/4#issuecomment-276224004, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWlelRNpQh40jhLKeZhQOLlWvtBL_TFks5rXnBMgaJpZM4Lx-do .
Converted to es5.
Rad! - oh also @toddself just pointed out we can now just reuse the react and preact code; e.g. alias it - that's like really cool :D
On Mon, Jan 30, 2017 at 4:07 PM Kye Hohenberger notifications@github.com wrote:
Converted to es5.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/yoshuawuyts/nanocomponent-adapters/pull/4#issuecomment-276232959, or mute the thread https://github.com/notifications/unsubscribe-auth/ACWlelJ-FOPgIXZMfHaZ2GY8iG_oddZkks5rXntDgaJpZM4Lx-do .
v1.2.0
:sparkles:
Heh - I didn't even need to say anything lol.
Regarding prototype methods, preact doesn't care what gets used - the only requirement is that there is a render()
method on the prototype. "Inheriting" from Component is just to get setState()
.
Preact does not have
createClass
. You can emulate it of course, but I did not know if you wanted to do that. Just let me know what you think and I will update PR if needed.2