DEV Community

JosephSam
JosephSam

Posted on

..map is not a function

Hi everyone am a newbie in react and have encountered this problem, need help
https://codesandbox.io/s/interesting-sara-q2j9w?file=/src/App.js

Top comments (3)

Collapse
 
juanfrank77 profile image
Juan F Gonzalez

Here, I fixed it for you. codesandbox.io/s/exciting-cdn-ip9w...
The issue was in the handleView method you were using the '!' on an array not a boolean.
Also, there was an issue in the mapping of teachers because React was missing the 'key' prop in order to render the teachers properly.

Collapse
 
unsuredev profile image
Jamaluddin Mondal

It was a small mistake @josephSam check what I changed here codesandbox.io/s/reverent-sun-oppw...

Collapse
 
mohammedik2005 profile image
Mohammed Al-Karasneh

handleView = e => {
e.preventDefault();
let ta = this.state.showPersons;
this.setState({
showPersons: !ta
});
};