Skip to content

giraud/babel-plugin-transform-react-compose-displayname

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Babel Plugin to add displayName to a component

Resources

License

Stars

Watchers

Forks

Packages

No packages published