Skip to content

jamiebuilds/babel-plugin-react-pure-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-react-pure-components


Optimize React code by making pure classes into functions

Note: Requires React v0.14 or higher.

Example

In:

class MyComponent extends React.Component {
  static propTypes = {
    className: React.PropTypes.string.isRequired
  };

  render() {
    return (
      <div className={this.props.className}>
        ...
      </div>
    );
  }
}

Out:

function MyComponent(props) {
  return (
    <div className={props.className}>
      ...
    </div>
  );
}

MyComponent.propTypes = {
  className: React.PropTypes.string.isRequired
};

Installation

$ npm install babel-plugin-react-pure-components

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["react-pure-components"]
}

Via CLI

$ babel --plugins react-pure-components script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["react-pure-components"]
});

About

Optimize React code by making pure classes into functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published