You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Andrei Glingeanu, Christopher Chedeau, Silvio Henrique, Saeed Madadi, AJ, Remek Ambroziak, Caleb Eby, Daniel Sockwell, Jacob Parker, Sergey Makarov and 127 more
Reacted by Aaron Cordova, Ryan Skinner, Gudjon, Vlad Derzhavin, Luke , Tripurari Shankar, Niklas Fondberg, ThisNameWasTaken, Dmitry Rogozhnikov and Jon
Reacted by Carlos Galarza, Aaron Cordova, shuzo, Ryan Skinner, Gudjon, Luke , Tripurari Shankar, strblr, Niklas Fondberg, ThisNameWasTaken and 4 more
Reacted by Joscha Rohmann, Daniel Sockwell, Peter Mikitsh, Max Milton, Keller Davis, Marvin Hagemeister, Ramrami Mohamed, David Luzar, Kaixuan Kang, Waseem Dahman and 81 more
Reacted by Ramrami Mohamed, Gary Bernhardt, Rafał Goławski, Silvio Henrique, Abdellah, Flouse, Oskar van Velden, Zack Young, Ruhul Amin, Nathan Vander Wilt and 29 more
Reacted by Joscha Rohmann, Ragnar Rognstad, Sasha Koss, Silvio Henrique, Abdellah, Flouse, Zack Young, Ruhul Amin, Ramrami Mohamed, Ilia Sidorenko and 32 more
What if all components stuff can also be moved into opt-in import?
Like import { Component } from 'preact/component'
So if you want to use only functional components and hooks you don't pay for component(Will|Did)...
Sure it's a breaking change but maybe someday...
Reacted by Ramrami Mohamed, David Luzar, Max Milton, Dmitry Panyushkin, Hugo Manrique, Phil, Anibal, Derek Shih, James Hegedus, darsain and 33 more
Moving components into their own sub-package sounds great, especially since they become useless if one go with hooks exclusively. So most projects could decide whether they want the OO style (/components) or the more FP style (/hooks)
Reacted by Benjamin Lupton, Avinash Dwarapu, ilpoo, v1rtl, Luke , casperan and OliverGrack
@AlexGalays it's unlikely that they'll become "useless" anytime soon. There are a lot of third-party components on npm and it will take a long time for them to change. And that assumes that all the authors do want to change to hooks in the first place.
@AlexGalays it's unlikely that they'll become "useless" anytime soon. There are a lot of third-party components on npm and it will take a long time for them to change. And that assumes that all the authors do want to change to hooks in the first place.
In order to move Component into a subpackage we'd need to disentangle it from the renderer. Right now it's plumbed directly into the renderer since setState and forceUpdate enqueue rendering. It seems like the only way to remove that direct dependence would be to export a secret member from Preact that can be used to call enqueueRender(). This could potentially be done the same way we do hooks (import {options} from 'preact'; options.enqueueRender()). I'm not sure what the savings would be though.
Reacted by Alexander Rusanov, darsain, Marvin Hagemeister, Alexandre Galays, Luke Lindsey, Will Bamford and mseddon
FYI: The hooks api will be part as an experimental feature of our next major release (titled: Preact X). The PR for it and a second one which optimizes bundle size was merged just before the weekend 🎉
Reacted by Ramrami Mohamed, Agron Kabashi, Benoît, Caleb Eby, weijarz, Anwar Jebali, Zeb Pykosz, Nathan Graule, Marius Reimer, Alexandre Galays and 13 more
FYI: The hooks api will be part as an experimental feature of our next major release (titled: Preact X). The PR for it and a second one which optimizes bundle size was merged just before the weekend 🎉
Great news! Dare I ask if there is an ETA on the release of X? 👀It sounds like it's going to be amazing 😃
Quick update: We're currently working on adding the last missing piece to hooks wich is the new context api via useContext. We originally didn't plan to include it in the initial release of Preact X but due to popular demand and widespread usage of createContext we decided to include it 👍 The PR's for it are already there and are awaiting review and some size reductions.
The downside is that this will slightly affect the release date. March seems like a more realistic estimate right now 👍
Reacted by Ramrami Mohamed, Dmitry Krylov, Brecht Carnewal, Caleb Eby, Todd, Daniel Sockwell, Alexandre Galays, Frank, Wayan jimmy, thadeu and 36 more
Reacted by 伊撒尔, Gage Peterson, Ragnar Rognstad, Laura buns, Luís Rodrigues, Kaio Duarte, menzen, Vince Navarro, Randall Tombaugh, Luke and 4 more
@marvinhagemeister umm is it possible to peek at the code somewhere? grepping for useState doesn't return anything in developit/preact, developit/* or marvinhagemeister/* :)
@xeoncross Updating our docs (and our site in general) is on our roadmap, but it's hard to tell when that will be finished. In Preact hooks work exactly the same as in React so their docs for hooks match perfectly. The only difference is the import: preact/hooks vs react 👍 💯
Reacted by David Pennington, Alexandre Cardim, Alexander Pravdin and ChenYong
I think I'm running into a compatibility problem with react-wordcloud. Running the example from the readme in a new Preact 8.4.2 app fails with
useRef is not a function
After installing preact@next and adding import { useRef } from 'preact/hooks', the error becomes
preact.js?10a9:1 Uncaught TypeError: Cannot read property 'default' of undefined
at rankChild (preact-router.es.js?bff2:82)
at prepareVNodeForRanking (preact-router.es.js?bff2:65)
at Array.filter ()
at Router.getMatchingChildren (preact-router.es.js?bff2:303)
at Router.render (preact-router.es.js?bff2:326)
Activity
developit commentedon Nov 2, 2018
It looks like we're going to be releasing hooks support as an opt-in import, so you only pay for them if you use them. It'll look like this:
There's been some discussion of this on Twitter - currently we have a working prototype.
huozhi commentedon Nov 3, 2018
@developit is there a current developing branch for hooks feature now?
arusanov commentedon Nov 8, 2018
What if all components stuff can also be moved into opt-in import?
Like
import { Component } from 'preact/component'So if you want to use only functional components and hooks you don't pay for
component(Will|Did)...Sure it's a breaking change but maybe someday...
hugmanrique commentedon Nov 10, 2018
Webpack should already (don't quote me on this) just remove the
Componentclass and all other functions you don't use in your code.SolarLiner commentedon Nov 10, 2018
Only with the proper tree shaking plugins? Or is it part of Webpack now and I've just lost touch (last option most likely)?
hugmanrique commentedon Nov 10, 2018
Webpack 4 does tree shaking in
productionmode (Source: https://webpack.js.org/guides/tree-shaking/) 😀arusanov commentedon Nov 11, 2018
While treeshaking will remove some, It won't be able to remove this code for example:
https://github.com/developit/preact/blob/master/src/vdom/component.js#L27
or this one
https://github.com/developit/preact/blob/master/src/vdom/component.js#L86
or this
https://github.com/developit/preact/blob/master/src/vdom/component.js#L200
AlexGalays commentedon Nov 18, 2018
Moving components into their own sub-package sounds great, especially since they become useless if one go with hooks exclusively. So most projects could decide whether they want the OO style (
/components) or the more FP style (/hooks)marvinhagemeister commentedon Nov 19, 2018
@AlexGalays it's unlikely that they'll become "useless" anytime soon. There are a lot of third-party components on npm and it will take a long time for them to change. And that assumes that all the authors do want to change to hooks in the first place.
AlexGalays commentedon Nov 19, 2018
Yes, I never wrote that though.
marvinhagemeister commentedon Nov 19, 2018
@AlexGalays Oh sorry, my bad. I misread your comment.
developit commentedon Nov 20, 2018
In order to move Component into a subpackage we'd need to disentangle it from the renderer. Right now it's plumbed directly into the renderer since setState and forceUpdate enqueue rendering. It seems like the only way to remove that direct dependence would be to export a secret member from Preact that can be used to call
enqueueRender(). This could potentially be done the same way we do hooks (import {options} from 'preact'; options.enqueueRender()). I'm not sure what the savings would be though.16 remaining items
marvinhagemeister commentedon Jan 28, 2019
FYI: The hooks api will be part as an experimental feature of our next major release (titled: Preact X). The PR for it and a second one which optimizes bundle size was merged just before the weekend 🎉
Anwardo commentedon Jan 28, 2019
Great news! Dare I ask if there is an ETA on the release of X? 👀It sounds like it's going to be amazing 😃
marvinhagemeister commentedon Jan 28, 2019
@Anwardo We're currently aiming for a beta/rc release around mid February. We'll post an announcement at that time with more info 🎉
marvinhagemeister commentedon Feb 6, 2019
Quick update: We're currently working on adding the last missing piece to hooks wich is the new context api via
useContext. We originally didn't plan to include it in the initial release of Preact X but due to popular demand and widespread usage ofcreateContextwe decided to include it 👍 The PR's for it are already there and are awaiting review and some size reductions.The downside is that this will slightly affect the release date. March seems like a more realistic estimate right now 👍
wizzard0 commentedon Feb 20, 2019
@marvinhagemeister umm is it possible to peek at the code somewhere? grepping for useState doesn't return anything in developit/preact, developit/* or marvinhagemeister/* :)
marvinhagemeister commentedon Feb 20, 2019
@wizzard0 Preact X currently lives in a private repo but will be merged soon into this one here. The switchover date is March 4th. See: https://mobile.twitter.com/marvinhagemeist/status/1097973028426788864 🎉
marvinhagemeister commentedon Mar 4, 2019
We just merged the PR for Preact X #1302 which includes the
hooksaddon. An alpha release should be available in a few hours 🎉xeoncross commentedon May 1, 2019
Any idea of when the hooks documentation / API reference will be live?
marvinhagemeister commentedon May 1, 2019
@xeoncross Updating our docs (and our site in general) is on our roadmap, but it's hard to tell when that will be finished. In Preact hooks work exactly the same as in React so their docs for hooks match perfectly. The only difference is the import:
preact/hooksvsreact👍 💯dandv commentedon May 22, 2019
I think I'm running into a compatibility problem with react-wordcloud. Running the example from the readme in a new Preact 8.4.2 app fails with
After installing preact@next and adding
import { useRef } from 'preact/hooks', the error becomesInstalling
preact-compatdidn't help.ForsakenHarmony commentedon May 22, 2019
you want
preact/compat, not the oldpreact-compatdandv commentedon May 22, 2019
@ForsakenHarmony: after removing
preact-compatand installingpreact/compat, I getForsakenHarmony commentedon May 22, 2019
do you have the latest
preact-router?