why am i not seeing the data in my screen when I map over "this.state.viciados" if i can see the data in the console? I have seen this problem in stack overflow but the only answer in that qustion doesn't work.
class App extends Component {
constructor(props) {
super(props);
this.state = {
viciados: []
}
}
componentDidMount() {
this.getViciados();
}
getViciados = _ => {
fetch("http://localhost:3000/dependentes")
.then(response => response.json())
.then(response => {
this.setState({ viciados: response.data })
//console.log(response.data);
})
.catch(err => console.log(err));
}
render() {
const viciados = this.state.viciados.map(viciado => {
console.log(viciado['id_viciados'], viciado["nome_viciado"]);
<div key={viciado['id_viciados']}>{viciado["nome_viciado"]}</div>
});
return (
<div className="App">
{viciados}
</div>
);
}
}
export default App;