score:2

Accepted answer
componentWillReceiveProps({ filename }) {
  if(filename !== this.props.filename) {
    this.loadItems(filename)
  }
}

loadItems(filename) {
    $.ajax({
      type: 'GET',
      url: `${this.props.url}${filename}.json`,
      headers: {
        'Authorization': "Token " + localStorage.token
      },
      success: (result) => {
        this.setState({
          items: result.child
        })
      },
      error: function(cb) {
        console.log(cb)
      }
    });
}

Related Query

More Query from same tag