TypeError: Cannot read properties of undefined (reading 'map')
Asked
Active
Viewed 42 times
2 Answers
0
One possibility is that the posts array is empty. We can help better if you show us the posts object

demiglace
- 405
- 1
- 5
- 12
-
It's not an empty array, it's undefined. It's the only possibility in fact from this code – ShamPooSham Oct 28 '21 at 20:36
0
Maybe posts is undefined at the first rendering because it comes from an async call.
export default function Post({ posts = []}) { ... }

Antonio Pantano
- 4,592
- 2
- 23
- 26
-
1Thanks very much. Did what you suggested and it works perfectly. Thanks again. – Arthur Hauya Oct 28 '21 at 21:52
-
If this solved the problem you can consider to accept the answer so that other users with the same problem can see the solution. – Antonio Pantano Oct 28 '21 at 22:02