W
W
Wink0072020-05-30 23:28:27
API
Wink007, 2020-05-30 23:28:27

Multiple react hooks API requests?

Guys, I'm a newbie, tell me please, is there, for example, a Home component in which I want to display three different queries? Is it possible to do this through hooks? If yes, then you can give an example, if not difficult

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-05-31
@Robur

maybe something like this

const [data, setData] = useState(null)
async function doStuff() {
  const data = await fetch(...)
  setData(data)
}
....
 <Button onClick={doStuff} />
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question