TypeError: banners.forEach is not a function (Error in NewPage.js)

0
Posted at May 17, 2021 55 Views . 0 Saved .
2 Comments
Amarpreet Singh Bhatia
Actually when I leave the banner and product image blank and then click on save, I have this error after that
Bilal Ullah Khan Bhatia
so you are saying that when you leave banners and products empty then you got this error but when you select images of banners and products then its fine
Amarpreet Singh Bhatia
Yes
Amarpreet Singh Bhatia
Just when I leave it blank this error happens
Bilal Ullah Khan
Check your variable declaration of banners and products It should be like this:- const[banners,setBannerd]=usestate([]); CHECK YOUR USESTATE HAVE YOU PASSED EMPTY ARRAY OR NOT.
Amarpreet Singh
Sorry for replying so late. Actually we have a problem in family. Once it's over I will in touch with you again. Till then please can you wait. Sorry sorry sorry!!!!
Bilal Ullah Khan
No problem Take your time.????
Amarpreet Singh Bhatia
Can anybody help me solve this please
Rizwan Khan
forEach only works with an array. You are getting error because your banners or products is not an array somehow you made a mistake in initializing those variables as array
Amarpreet Singh Bhatia
That I am not getting where did I made the mistake. I verified my code with yours but both are same. Can you help me where did I made the mistake. A rough guess may also help. Thank you