-1
the program takes data from an api and passes through a filter that returns to the component products that should render on the screen that list, which it does but the product data is not seem.
import Cards from '../function/card';
import renderlist from '../function/renderlist';
import {useEffect,useState } from 'react';
function Products(){
useEffect(() => {fetchData()}, []);
const [list,setlist]= useState()
async function fetchData() {
const res = await renderlist()
const list = res.map((valor) =><Cards value={valor} key={valor.name}/>)
console.log(list)
setlist(list)
}
return(<div>{list}</div>)
}
export default Products;
the components are rendered on the screen but the data passed does not appear, the cards Components.
function Cards(unid){
return(
<div>
<img alt={'aqui'} url={unid.url} ></img>
<h1>aqui</h1>
</div>
)
}
they appear on the screen with the right amount but does not appear the information passed in the parameters, just appears empty Ivs. I checked the list and it looks like a list of objects of type {$$typeof: Symbol(React.element). what appears on the user screen only the "here" the other data does not appear, but appear the span and img so that empty...
where are you calling:
fetchData()
?– novic
in useeffect, I don’t know why it didn’t show up there, but I’ve fixed it
– morata100
if you did wrong, dice you keep in on the variable
list
and in thelist
you use themap
and shows the component, the way you did just created aarray
component– novic
could explain me little better ? I am little lost
– morata100