compconv

0.1.2 • Public • Published

compconv

Convert React component between function and class.

Install

npm install compconv

If you are using Yarn,

yarn install compconv

Usage

Let's convert a functional component to a class component.

import compconv from 'compconv';
 
const input = `export default ({ foo, bar  }) => {
  return (
    <div>
      This is {foo} {bar}
    </div>
  );
};`
 
const output = compconv(input);
 
// output is:
//
// export default class MyComponent extends React.Component {
//   render() {
//     return (
//       <div>
//         This is {this.props.foo} {this.props.bar}
//       </div>
//     )
//   }
// }

It also works the other way around.

License

MIT

Package Sidebar

Install

npm i compconv

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

111 kB

Total Files

13

Last publish

Collaborators

  • sungwoncho