0

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?

3
  • 2
    Please use react as intended or don't use it at all Commented Oct 10, 2022 at 10:45
  • what is wrong in trying out and learning the things. Commented Oct 10, 2022 at 10:49
  • Everything, you didn't use react at all reactjs.org/tutorial/tutorial.html Commented Oct 10, 2022 at 10:49

1 Answer 1

1

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

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.