Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 1.5 KB

File metadata and controls

77 lines (54 loc) · 1.5 KB

Private babel plugin that can:

  • rewrite memoization function to add key based on module/function name
  • (obsolete) add a displayName to a component created by composition, using reactStamp or another function.

npm version

Installation

$ yarn add -D babel-plugin-transform-react-compose-displayname

Usage

babel.config.js

module.exports = {
    plugins: ['transform-react-compose-displayname']
}

You can specify options:

module.exports = {
    plugins: [
        ['transform-react-compose-displayname', { methodNames: ['compose'] }]
    ]
}

Rewrites

Memoize

in

module Selectors = {
  let getValue = (. store:store) => Reselect.memoize1(input, (input) => { ... }); 
};

out

let getValue = (store) => memoize('ModuleName:getValue', [input], (input) => { ... });

Add display name

in

const MyComp = reactStamp(React).compose({
  render() { ... }
});

out

const MyComp = reactStamp(React).compose({
  render() { ... }
});
MyComp.displayName = 'MyComp';

Links

License

MIT