Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
How to import other file with react

now i'm doing add react to website from this tutorial react Tutorial. I don't run this react with node so i just build in with add DOM Container to the HTML. However i struggle to integrate other file in a same page. i share my code

this on file index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Add React in One Minute</title>
    <script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" >
 
    
  </head>
  <body>
    <div id="root"></div> 
    <script type="text/babel" src="./App.js"></script>
    <script type="text/babel">
        ReactDOM.render(<App />, document.getElementById("root"));
    </script>
    
  </body>
</html>

this my code on app.js

 class App extends React.Component { 
    render() {
      return(
        <div>
           <img src="<logoURL>"/>

           <div id="homeSite"></div> 

           <script type="text/babel" src="./Home.js"></script>
           <script type="text/babel">
               ReactDOM.render(<Home />, document.getElementById("homeSite"));
           </script>

        </div>  
      )
    }
  }  

and this my code on home.js

class Home extends React.Component { 
  
    render() {
      return(
        <div >
            test home display text
        </div> 
      )
    }
  }

i got 2 warning error

Uncaught ReferenceError: require is not defined

other is this

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

i not sure how to resolve this. please help

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

In index.js you can not write html code, for html code you have to use index.html file that located in public dir. in index.js write like below

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(
  <React.StrictMode>
    <App />
 </React.StrictMode>,
  document.getElementById('root'),
);
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!