im starting to study React JS, so Im trying to build an app that makes cotation and I
m trying to pass the cotation value as a prop.
But it doesn work. Please help!
Thanks!!
import './App.css';
import RealDolar from './components/real_dolar.js';
function App() {
let realDolar = 0;
let url = 'https://api.freecurrencyapi.com/v1/latest?base_currency=USD¤cies=BRL&apikey=xyz';
fetch(url).then(res=>{
return res.json()
}).then(json=>{
realDolar = json['data']['BRL'];
})
return (
<div className="Real_Rapido">
<RealDolar cotacao={realDolar} />
</div>
);
}
export default App;
3
Answers
worked with this..
Hi! You need to use
useState
anduseEffect
hooks.Learn more about hooks: https://react.dev/reference/react/useState and https://react.dev/reference/react/useEffect
The passed prop should be a state: