Let's say I have a console.log in a render method of a component:
class MyComp extends React{
render(){
console.log('rendering')
return <div>Hello</div>
}
}
Whenever this component renders I'll see it in the console. Does that always mean that the Virtual Dom is re-rendering?
Put another way, is logging the render method a good way to know if the non-virtual DOM is re-rendering?
Whenever this component renders I'll see it in the console. Does that always mean that the Virtual Dom is re-rendering?
Yes, you are right, Virtual Dom is re-rendering.
Put another way, is logging the render method a good way to know if the non-virtual DOM is re-rendering?
Putting console to render method is good and simple way to know when your component is updating.
There are 3 cases (as i know) when react component is re-rendering
You can read more here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.