React child Component in parent Component
Solution 1:
The problem is quite clear: The Button
component does not return anything when the conditions do not match.
You just need to add a simple return null
at the end of the render method for Button
:
render() {
const btn = this.props;
...
return null;
}
Another option is to add one of the missing props to the Button
when you use it:
<Button theme="primary" type="button">Contact us</Button>
or
<Button theme="primary" type="link">Contact us</Button>
In either case, I recommend you keep the return null
inside the render
method.