There is React component that should be rendered or shouldn't be rendered according to some conditions.
And I can do like follow
class Parent extends React.Component{
render(){
{condition() && <Child />}
}
}
Until now, It's OK, but problem is there are pretty many Parent component in my project.
So I wanna put condition() function in Child Component like following
class Child extends React.Component{
render(){
{condition() && <div>Child Component rendered!!</div>}
}
}
class Parent extends React.Component{
render(){
<Chile> {/* type nothing */}
}
}
But unfortunately, Chile component have ComponentDidMount() function.
And that function do pretty many thing.(like ajax call..)
How can I prevent calling React related functions?(like ComponentXXX...)
Is there any good way?