I have an MDL working with React at the moment, and currently it is working fine.
I have a progress bar that appears on the page as needed, and it loads with the specified "progress" when the page loads with direct input of the number:
document.querySelector('#questionnaireProgressBar').addEventListener('mdl-componentupgraded', function() {
this.MaterialProgress.setProgress(10);
})
or when passing a number through a variable:
document.querySelector('#questionnaireProgressBar').addEventListener('mdl-componentupgraded', function() {
this.MaterialProgress.setProgress(value);
})
It stops working after that. I am trying to update a value through a variable and not being updated. I was recommended to use this:
document.querySelector('.mdl-js-progress').MaterialProgress.setProgress(45);
to update the value, but it does not work. Even when you try it right in the console.
When trying through the Console, I get the following error:
Uncaught TypeError: document.querySelector(...).MaterialProgress.setProgress is not a function(โฆ)
, , console.log(), (1,2,3,4...) , ( , )
, - , MTL React, ? , , , โโ :
updateProgressBar: function(value) {
var _this = this;
document.querySelector('#questionnaireProgressBar').addEventListener('mdl-componentupgraded', function() {
this.MaterialProgress.setProgress(value);
})
},
, , "componentWillReceiveProps" , .
"componentDidMount", , , . , , , "componentWillReceiveProps" "componentDidMount".
- , . - , .
updateProgressBarTotal: function(questionsAnsweredTotal) {
this.props.updateProgressBarValue(questionsAnsweredTotal);
}
( , ):
updateProgressBarTotal: function(questionsAnsweredTotal) {
this.setState({
progressBarQuestionsAnswered : questionsAnsweredTotal
})
}
.