-3

Lets say I have Test1.html,Test2.html, Test3.html ...etc files having different form data. I want to generate reactJS components like Test1.js, Test2.js Test3.js components with complete information.

we have idea like one common reactjs plugin to take any html file as input and automatically converts react components. As a developer no need to write separate code for converting their own component from html file. just i want to make it plugin

just upload the html file as input and generate the reactjs component with complete data.

make it .html files are input and expected output is react component.

Please let me know any one how to do this that would be great????

  • This may be possible in the completely trivial case of "dumb" presentational components consisting only of HTML elements but anything more than that will be very difficult. It sounds like you're asking for something magic here. – Tom Fenech Aug 30 '16 at 09:16
  • let me give clarity onthis var htmlInput = '

    Title

    A paragraph

    ';//upload html file var SampleOneComponent = React.createClass({ render: function() { return ( htmlInput; ); } });
    – vallepu veerendra kumar Aug 30 '16 at 09:23

1 Answers1

0

It's not a good idea. I don't know if you need to perform some operations with state in your react components or just need the html. If you only need to have html in render(), you can do something like that:

componentWillMount() {
    // get your data from html
    ...
    this.data = your_data;
}

render() {
    return (
        <div dangerouslySetInnerHTML={{__html: this.data}}></div>
    );
}

But again, it's not recommended !

Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51