ts-react-pure-class-plugin
A TypeScript AST Transformer that transform class based stateless pure component to functional component.
Example
from
to
; { return React;} rewrited_pure_class_1;
How to use
before:
Notice
if you want to use this plugin, please make sure there're no components were described like following code, otherwise, the transformation will break your app.
In most situations, you can just mark Foo as abstract class to skip the optmization and solve the problem.
Option
pureClsPluginoption?: Option
Deopt
if transformer meets one of following conditions, optmization will be skipped.
- contain react component lifecycle
- contain state
- contain getter/setter
- contain decorator
- contain static property
- abstract class
- not a pure component
- a special comment directive
- non-top-level class
Deopt directive
/*@__DEOPT__*/
License
Apache-2.0