When I return null from a stateless function I receive an error message. I would like to know what's the reason that a stateless function cannot return null.
Here is my sample code:
const MeetingMembers = ({ members, isLoading, error }) => {
if (isLoading) {
return <i className="fa fa-spinner fa-spin" />;
}
if (error) {
return <div className="alert alert-danger">{error}</div>;
}
if (!members) {
return null; // if no members was passed the component should'nt be displayed yet
}
return <pre>{JSON.stringify(members, null, 2)}</pre>;
};
Thank you.