反应打字稿 林特: 否则 如果 : 错误 "返回"之后不必要的"else"



我在下面的else-if上得到以下错误。我已经删除了最后一个纯Else语句,Lint仍然在ElseIf上给出错误。我该如何解决?

error在"return"之后不需要"else">

const renderBody = () => {
if (loading) {
return <Skeleton variant="rect" width="100%" height={130} />;
} else if (productListData?.length > 0) {
return (
<Box width="100%">
{productListData?.map(product => (
<ProductCollectedRow
key={product.productId}
patientId={patientId}
serviceLocationGuid={serviceLocationGuid}
product={product}
receiptRequest={receiptRequest}
/>
))}
);
}
return (
<Box
width="300px"
height="150px"
border={1}
borderColor="grey.300"
display="flex"
justifyContent="center"
alignItems="center"
>
No products collected yet
</Box>

由于如果加载则返回,else关键字在else if中是多余的,因此只需删除它并只保留if

最新更新