Open
Description
do { ... }
expressions are now stage 1 and have been supported by Babel for a while.
They're especially useful in JSX, as they help you avoid nested ternaries. It would be great to be able to use them in a Flow project.
const View = ({ loading, error, ...otherProps }: Props) => (
<div>
{do {
if (loading) {
<Loading />
} else if (error) {
<Error error={error} />
} else {
<MyLoadedComponent {...otherProps} />
};
}}
</div>
);
NB. This feature was being tracked as part of a long list in #560, but that issue seems to have been forgotten and buried since 2017. I suggest closing that one and opening individual issues for the few remaining ES-next features if they're still wanted.