Reputation: 1
Now my Container looks like this. But i don't think it's best way.
renderAddForm() {
if (!this.props.isFetching) {
return <div>loading</div>;
}
return <AddForm {...this.props} />;
}
render() {
return (
<Layout>
<PageHeader title="Ангилал нэмэх" button="Хадлгалах" href="#" />
{this.renderAddForm()}
</Layout>
);
}
Upvotes: 0
Views: 365
Reputation: 1836
Your solution it's fine. Another way could be inline:
render() {
let { isFetching } = this.props
return (
<Layout>
<PageHeader title="Ангилал нэмэх" button="Хадлгалах" href="#" />
{isFetching ? <div>loading</div> : <AddForm {...this.props} />}
</Layout>
);
}
Upvotes: 3