1

Is there a way to load the react file inside Javascript files? No library and no nodeJs

my code :

main.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="app.js" type="module"></script>
</head>
<body>

</body>
</html>

app.js

import React from './react.development.js';
import ReactDom from './react-dom.development.js';

1 Answer 1

1

Use the CDN links to acquire React and ReactDOM:

main.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div id="root"></div>

    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    <script src="app.js" type="module"></script>
</body>
</html>

No need to import React, and ReactDOM, since they are now globally available.

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.