Open Rafi993 opened 4 years ago
This idea has come up a few times since hooks were unveiled. The problem is that there are tons of third party libraries out there which depend on the class-API. Removing it from Preact would break a huge chunk of our ecosystem. It's an idea we keep in mind, but can't execute on right now.
That is true. I am not talking about removing it from the repo but creating separate build (using some script ) in addition to the default build for people who want to use it and with warning that it may not work third party libraries that use components.
It will provide users with option to use hooks only build instead of default build for specific use cases where there is no external react libraries used (or using only libraries that are hooks specific) in exchange for reduction in bundle size.
The class API is an integral part of our core. It is not an add-on like our the hooks implementation, so we can't just remove it via build scripts currently.
That said if you want to take up the work of extracting classes, we're happy to guide you along the way. Most of the class specific code can be found in diff()
. That's likely where you'd need to start 👍
Awesome. I will try creating a PR for this.
Sorry for closing this one prematurely.
No issues
You might want to have a look at #2102
Hmm, #2102 moves a few internals but we still have to test if it actually improves performance.
The most important part to preserve functionality will be to move _forceUpdate
to the vnode so useReducer
can call vnode.forceUpdate() instead of setState. About the components I still have to think about the best approach.
Would anyone mind kindly confirming that this is a storybook/preact issue, and not a preact issue: https://github.com/storybookjs/storybook/issues/10140#issuecomment-623000179 ?
@CaffeinateOften Please don't hijack issues that are completely unrelated and open a new one instead. Otherwise it quickly becomes impossible for us maintainers to track them.
It would be awesome if there is a Preact build that removes Component class and related code from it and just has support for hooks alone. So that build size is further reduced for code that will only be using hooks alone instead of class related components. Is there any plans on this ?