My problem is that when I send Array of data as prop and console.log it in another component , it first shows "undefined" and then it shows the data. I get data from API and then send it as prop to another component. I already removed React.strictMode from index.js file but it still keeps happening.
for example :
const menu = [
{name : "firstFood"},{name:"Second Food"}
]
<MenuTable menu ={menu} />
and in other component I console.log it.
const MenuTable = (props)=>{
console.log(props.menu)
}
In first render it shows undefined then it shows data
I think you wrote:
const [menu, setMenu] = useState()
Then you call the api and setMenu(response) with the data response.
Therefore, menu, at first, is undefined. You should try useState([]), then the first render of menu is [].