return
возвращает объект, а не jsx.Попробуйте это
type MyType = {
name: string,
};
constructor(props) {
super(props);
this.state = {
obj: null
};
}
componentDidMount() {
this.setState({obj: {name: 'Vasya'}});
}
render() {
return (
{this.state.obj && <MyComponent />}
);
}
или это:
type MyType = {
name: string,
};
constructor(props) {
super(props);
this.state = {
obj: null
};
}
componentDidMount() {
this.setState({obj: {name: 'Vasya'}});
}
render() {
if (this.state.obj)
return <MyComponent />;
else
return null;
}