0

For example, here is some of my React codes.

class App extends Component
{
    render(){
    return (
        <div className="App">
            <Header/>
            <LoginApp />       
            <Register />
            <Footer />      
        </div>
        );
    }
}
export default App

Now, I'd like to include the warning panel into this class, but the file was written using just only simple HTML and JavaScript codes. Is there any ways to load the dot html files into the React component class?

Here's the idea.

<div className="App">
        <Header/>      <--React Component 
        <LoginApp />   <--React Component      
        <Register />   <--React Component 
        <Footer />     <--React Component 
        // Load other external html files here... (Non React component)/
</div>

Thank you very much.

PS.I'm extremely new to React.

7
  • Why don't you make a component for it. This will help you in the long run Commented Jul 9, 2018 at 8:06
  • Not in a very easy way. Just convert the HTML to a React component (with something like transform.now.sh/html-to-jsx) and rewrite the JavaScript to be React-y. Commented Jul 9, 2018 at 8:08
  • Yep, that's one way of getting it done, but I'd like to know if it's possible or not. Commented Jul 9, 2018 at 8:09
  • @user3505908 use this package ==> html-loader Commented Jul 9, 2018 at 8:10
  • @user3505908 check this solution ==> stackoverflow.com/a/46997182/4468132 Commented Jul 9, 2018 at 8:11

1 Answer 1

0

There are 2 ways for that

Fetching HTML or Setting as Inner HTML

visit this link, There is a code for explain how to do this Add html file to a react component

also this will help Add react to a simple HTML file

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.