Extract annotated portions of HTML into React components as separate modules
npm install html-to-react-components-es6Extract annotated portions of HTML into React components as separate modules. The structure of HTML is preserved by importing child components and replacing appropriate pieces of HTML with them. As a result you get an entire components tree ready to be rendered.
```
$ npm i -g html-to-react-components-es6
HTML components should be annotated with data-component attribute. The value of the attribute is the name of the React component.
See and run node try.js for usage example and output.
``
$ html2react ./src/*.html
`js
import htmlToReact from 'html-to-react-components-es6';
var components = htmlToReact(
);
console.log(Object.keys(components))
/*
["Header", "Heading", "ListItem", "Nav"]
*/
console.log(components['Header'])
/*
import React from 'react';
import Heading from './heading';
import Nav from './nav';
class Header extends React.Component {
render() {
return (
);
}
}
*/
`
Wether write to file or not.
Default is true for cli and false for api.
Output directory. (only useful when outputType is file)
Default is components directory in the current directory.
Output files extension. (only useful when outputType is file)
Default is jsx`.