2

I have been looking for a solution for this problem but it remains. I read about the setTimeout but it didn't work or may be I didn't use it the right way
This is my code

constructor(){
    super();
    this.state={
        message:[],
        socket: io.connect('http://'+ip+':3000')
    }
    this.Submit = this.submitMessage.bind(this);
}
componentWillMount(){
    let newMessage = this.state.message.slice();
    fetch('/get',{method:'POST'})
        .then(function(res){
            return res.json()
        }).then(function(body){
            _.map(body,(x,i)=>
                newMessage.push({'name':body[i].name, 'content':body[i].content})
            )
        })
    this.setState({message : newMessage});
}   

and it returns
enter image description here
Anyone can help me ?

Jin DO
  • 59
  • 7

0 Answers0