-1
I started my React studies yesterday so I don’t have much knowledge about, and I’d like to know how to give a document.getElementById()
in React/JSX, how do I do this?
I tried to use document.getElementById()
like I said and tried to App.getElementById()
, but it didn’t work out either way...
I have the following code in my App.js:
import React from 'react';
import Header from './components/header';
import Input from './components/inputNum';
import Btn from './components/button';
function getURL() {
var url = App.getElementById("input-url").value;
console.log(url);
}
const App = () =>
<div className="App">
<Header />
<div className="content">
<h1>Vídeos</h1>
<Input id="input-url"></Input>
<div className="button-container">
<Btn onClick={getURL} id="btn-geturl"></Btn>
</div>
</div>
</div>
export default App;
There is already the possibility to use Hooks in React, such as using useState. There is no longer a need to create classes.
– Jonathan CR