aaronshaf / react-toggle

Elegant, accessible toggle component for React. Also a glorified checkbox.
http://aaronshaf.github.io/react-toggle/
MIT License
947 stars 159 forks source link

Checked status not updating on state change through xmlhttprequest listener #162

Open kaushalvivek opened 4 years ago

kaushalvivek commented 4 years ago
checkDeploymentStatus(modelId) {
    var xhr = new XMLHttpRequest()
    xhr.addEventListener('load', () => {
      if (xhr.responseText ==="deployed") {
        this.setState({
          isModelDeployed: true,
          modelInferenceAPI: MODEL_INFERENCE_API+'/'+this.props.modelVersion.run_id,
        });
      }
      else {
        this.setState({
          isModelDeployed: false,
          modelInferenceAPI: "Nor Deployed",
        });
      }
    });
    xhr.open('GET',MODEL_DEPLOYMENT_URL+"?runId="+modelId)
    xhr.send()
  }

This would update the state, but the state would not be reflected in the toggle.