Can I use setstate inside the callback function of the setstate '''this.setstate(update,function(){this.setstate}.bind)''' is the above given code correct and will it work
            Asked
            
        
        
            Active
            
        
            Viewed 72 times
        
    0
            
            
        - 
                    1yes, you can. . – Jonas Wilms Feb 16 '20 at 13:43
- 
                    Yes see : https://upmostly.com/tutorials/how-to-use-the-setstate-callback-in-react – Hamid Shoja Feb 16 '20 at 13:50
- 
                    And will that thing give immediately effect to state ?? – Raunak Thakkar Feb 16 '20 at 13:51
- 
                    Does this explain your question? https://stackoverflow.com/questions/42038590/when-to-use-react-setstate-callback – Hamid Shoja Feb 16 '20 at 13:53
- 
                    I'm sorry it kind of doesn't actually I know when to call it, but calling setstate inside callback will it give immediate change to the state – Raunak Thakkar Feb 16 '20 at 14:02
1 Answers
0
            
            
        this.setState({
 someState: newValue,
}, callback);
above code is using callback function in setState.
so you may write code like this.
this.setState({
 someState: newValue,
}, () => {
 // some code you want
});
 
    
    
        gnujoow
        
- 374
- 1
- 3
- 16
