Relaks-transform-memo
This Babel plugin simplifies development of Relaks application by automatically memoizing asynchronous components.
Before:
; { const show = ; /*...*/}
After:
; const Widget = Relaks;
Usage
This plugin is bundled with Relaks. There is no need to install it separately. In your Babel config, simply add it to the list of plugins:
plugins: '@babel/transform-runtime' '@babel/proposal-nullish-coalescing-operator' '@babel/proposal-optional-chaining' /* ... */ 'relaks/transform-memo'
Anonymous function
This plugin will also add names to components created through calls to Relaks.memo()
, Relaks.use()
, React.memo()
, and React.forwardRef()
.
Before:
; const Widget = React;
After:
; const Widget = React;
Custom higher-order components
You can instruct the plugin to add names to your own higher-order components by setting the otherHOCs
option:
plugins: /* ... */ 'relaks/transform-memo' otherHOCs: 'Tooltip.create'
Before:
; const Hello = Tooltip;
After:
; const Hello = Tooltip;