Answer the question
In order to leave comments, you need to log in
How to render an element?
The simplest task that can be: an array of objects comes from the backend, you need to render them.
[{}, .... {}]
async function fetchData() {
try {
const result = await axios
.get("http://localhost:8000/directories");
console.log(result.data);
setDirectories(result.data);
}
catch(error) {
console.error(error);
}
}
{
directories && directories.map((directory, index) => {
<Directory
key={ index }
label={ directory.name }
/>
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question