Skip to content

componentDidMount wouldn't not rerendering the component #8144

@jw-foss

Description

@jw-foss

Look , I got this problem, it shows on my console. which is
app.js:1 Uncaught TypeError: Cannot read property 'getHostNode' of null
and I don't know wtf is this Error, and another serious problem is here ,
here is my code :

componentDidMount() {
    console.log('mounted')
    getData(function (data) {   //get data from my backend
      console.log('got data: ' + data);
      this.setState({
        data: data
      })
    }.bind(this))
  }
  //data fetching function
  render() {
    console.log(this.state.data); // I loged this on my console. it should log twice right? 
    const log = this.state.data.filter(val => val.code == this.props.params.id)[0]; 
    console.log(log) // this will log twice as well 

and here is my log

[]
undefined

and that's it , I know this code may not look very good , but this problem is killing me , I try to debug it but I just can't

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions