keul
New Member
Posts: 4
|
Post by keul on Dec 15, 2020 16:31:11 GMT
augmentor documentation dismiss useContext hooks by simply redirecting to React.js documentation, but integrating a context hook inside a hooked-elements application is not so straightforward.
Any example to share?
|
|
|
Post by webreflection on Dec 15, 2020 17:29:58 GMT
Differently from React, augmentor requires a ` const ctx = createContext(initialValue)` reference to pass around as ` useContext(ctx)`, and the way callbacks get updated is by using ` ctx.provide(newValue)`. There are few closed issues around context, with also some usage example: github.com/WebReflection/augmentor/issues/27#issuecomment-626859548I understand this is not awesome, but I haven't used myself context too much, but if I can find other examples, I'll share these in here.
|
|
keul
New Member
Posts: 4
|
Post by keul on Dec 16, 2020 8:25:05 GMT
Differently from React, augmentor requires a ` const ctx = createContext(initialValue)` reference to pass around as ` useContext(ctx)`, and the way callbacks get updated is by using ` ctx.provide(newValue)`. There are few closed issues around context, with also some usage example: github.com/WebReflection/augmentor/issues/27#issuecomment-626859548I understand this is not awesome, but I haven't used myself context too much, but if I can find other examples, I'll share these in here. Thanks! Can I suggest you to improve the augmentor doc with an example like this? The .provide is something totally unexpected.
|
|
|
Post by webreflection on Dec 16, 2020 11:24:39 GMT
Thanks! Can I suggest you to improve the augmentor doc with an example like this? The .provide is something totally unexpected. I hope this live example makes sense, it's based on the new µhooks which might replace augmentor but it's basically the same API
|
|
keul
New Member
Posts: 4
|
Post by keul on Dec 17, 2020 8:02:49 GMT
Clear enough, thanks! BTW: should I expect an µhooked-elements package to replace hooked-elements then?
|
|
|
Post by webreflection on Dec 18, 2020 12:59:30 GMT
no, wicked and hooked elements are already essential and small enough, but I am working on uhooks and uhooks-dom which *should* improve performance and produce a smaller bundler ... but wicked/hooked-elements won't change at all, these are very stable and reliable, no need to change name or rewrite these 👋
|
|
|
Post by webreflection on Dec 24, 2020 15:41:10 GMT
P.S. hooked-elements is now smaller than ever and based on uhooks ... 2.2.0 is the latest update that makes it smaller, better, stronger, faster 👋
|
|