I am trying to make a page consuming an API with react, but the question arose: What is the correct way to show the value of a variable in react?
I know you can do something like:
<h2>{variable}</h2>
But being inside a function, it doesn't let me do that, I have it like this:
const callback = (res) => {
const htmlCity = document.getElementById('city-name')
let cityName = res.data.name //Esta es la variable que quiero mostrar
htmlCity.innerHTML = `City: ${cityName}`
}
And the html like so:
<h2 id="city-name">City: </h2>
Thank you very much for your reply