Answer the question
In order to leave comments, you need to log in
How to scatter over REACT components?
Actually there is a Todos component
render() {
const { data: { loading, error, todos } } = this.props;
if (loading) {
return <p>Loading...</p>;
} else if (error) {
return <p>Error!</p>;
} else {
return (
<ul>
{todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul>
);
}
}
Answer the question
In order to leave comments, you need to log in
const Error=()=>{
<div><p>Error!</p></div>
}
const Loading=()=>{
<div><p>Loading...</p></div>
}
const Todos=()=>{
<div><ul>
{this.props.todos.map(({ id, text }) => (
<li key={id}>{text}</li>
))}
</ul></div>
}
render() {
const { data: { loading, error, todos } } = this.props;
if (loading) {
<Loading>
} else if (error) {
<Error>
} else {
return (
<Todos todos={todos }>
);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question