To render the list fetched from dummy API.
The Code
App.js
import logo from './logo.svg';
import Header from './components/Header';
import MapArea from './components/MapArea';
import Card from './components/Card';
import './App.css';
import React from "react";
class App extends React.Component {
constructor(e){
super();
this.state = {
menu:false,
userData:[]
}
}
componentDidMount() {
fetch("https://reqres.in/api/users?page=2")
.then((a)=>{return a.json()})
.then((b)=>{
this.setState({
userData:b
})
})
}
Card.js
function Card(props){
let userData = props.data.userData.data;
console.log(userData) //Sometimes WORKING FINE
return(<div>{userData.map((item)=>{<h1 key={item.id}>item.id</h1>})}</div>)
}
export default Card;
The Problem
Now the thing is that sometimes the console.log works and sometimes it doesnt. Then I have to remove the javascript "{}" in render method of the Card.js and save and again paste it back and save. I have also added image of console when the console.log doesnt work
Also the list doesnt render.
