Is there any way to get props in React class other than in render method?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Is there any way to get props in React class other than in render method?



I can get all props passed in React class in its render method.
But if I try to do the same in componentDidMount() or even in constructor() - no luck.


render


componentDidMount()


constructor()



When debugging I can see props in


componentDidMount(){
const { users } = this.props <-props are already there
console.log('users from did mount', users); <-- undefined here
}



and nothing appears in users variable.


users



When the same code fires in render() method -- all is working fine.


render()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name