sam
sam

Reputation: 127

How to load data from react to index.html

I have a requirement where I have to load some data from React to an input field index.html. I have created:

<div id="root"></div>
<input type="text" id="input" name="fInput">

and in index.js I am trying to access it and assign a value to it.

const root = ReactDOM.createRoot(document.getElementById("root"));
const myInput = document.getElementById("input");
myInput.value= "test";

But it is not working, can anyone help me with this?

Upvotes: 0

Views: 301

Answers (1)

thvroyal
thvroyal

Reputation: 156

You should have a <script> tag in index.html to import index.js

Upvotes: 1

Related Questions