You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// render loading when data is a promise & render DisplayComponent when data is fulfilled
const { data } = this.props;
return (
<Card>
<DisplayComponent data={data} />
</Card>
);
They are not equivalent, and the new implement need data to be a promise to work.
So we can catch data as if (typeof data.then === 'function) { await data; }'
It may be more obvious if react release its Suspense
I think it is a later feature, but worth discussing.
Thanks for your advice.
Since consider of compatibility with react (15.x or 16.x which not support suspense), we will not include the suspense feature until old version of react not support yet.
What problem does this feature solve?
We can change
to
They are not equivalent, and the new implement need
data
to be a promise to work.So we can catch data as
if (typeof data.then === 'function) { await data; }'
It may be more obvious if react release its Suspense
I think it is a later feature, but worth discussing.
What does the proposed API look like?
componentDidCatch
demo@
otakustay
demo@react
The text was updated successfully, but these errors were encountered: