I just started learning about react/react-native. And I just saw an entry point file where there is a class and it has a render function. So technically, this render function will be called when a state of it gets changed. Even the states of its child components. So in order to make the child components not to be rendered, we are doing conditional rendering. It makes me to see the render function with pity.
For Example:
If we expand the main render function (entry point's render function), the jsx
will look something like this.
<Component1>
{ !!noSession &&
<Component2>
...
</Component2>
}
{ !noSession &&
<Component2>
{ !!spinnerNeeded &&
<Component3>
...
</Component3>
}
<Component4>
...
</Component4>
</Component2>
}
</Component1>
So, when a user gets logged in, the noSession
flow will no longer be rendered until the session gets cleared. So each and every time, when a child's state belongs to session
flow gets changed, all the unnecessary conditions (!!noSession
, !!spinnerNeeded
, etc..) would be validated. Why is that? Won't it drain the performance, if the components tree becomes huge?
Or Am I misunderstanding the react's way of working?