Monday 12 June 2017

Material-UI can only update mounted or unmounted component

I know, there are many questions with this title, but i didn't find any solution. The component is not using any ComponentWillMount, ComponentDidMount, etc

Trying to integrate LineProgress from material_UI.

Console logging the percentage works fine, but trying to change the completed state with that same percentage (so it can update the progress bar), it's yelling at me:

enter image description here

React Component

import download from '../download'

class DownloadFile extends Component {
     constructor(props) {
        super(props)
        this.state = {
            completed: 0,

     progressData(percentage) {
        console.log(percentage)
        this.setState({completed: percentage})
    }

    render() {
        <LinearProgress mode="determinate" value={this.state.completed} />
    }

Node helper file

var DownloadFile = require('../components/downloadFile')

static showProgress(received, total) {
    var downloadFile = new DownloadFile
    var percentage = (received * 100) / total;

    downloadGame.progressData(percentage)

}



via Cristian Muscalu

No comments:

Post a Comment