saga React.js 中的 setTimeout 函数

Has*_*eed 6 javascript saga reactjs redux-saga react-redux

我只想在 5 秒后隐藏 UI 中的撤消按钮。这是我的代码:

Saga.js

function* updateActionListingsSaga({ payload }) {
  try {
    const res = yield call(updateUnpublishedListingsById, payload);
    let unpublishedListings = yield select(UnpublishedListings);
    if (res) {
      const row = unpublishedListings.listingsData.results.find(data => data.id === res.ids[0])
      if (row) {
        row.review_status = payload.review_status
        row.isUndoEnabled = true;
        yield setTimeout(() => {row.isUndoEnabled = false}, 5000)
      }
    }
    
    yield put(updateActionListingSuccess());
  } catch (error) {
    yield put(apiError(error.error || error.message || error));
  }
}
Run Code Online (Sandbox Code Playgroud)

索引.js

item?.isUndoEnabled && (
  <ConfirmDialogBtn
    button={{
      color: 'primary',
      title: 'Undo',
      icon: 'bx bx-undo',
    }}
    msg="Set this Listing as Undo"
    onConfirm={() => handleUpdateListing(item?.id, 'pending')}
  />
)
Run Code Online (Sandbox Code Playgroud)

我正在检索特定行,通过附加row.isUndoEnabled= true属性设置撤消按钮,并在 5 秒延迟后将其设置为row.isUndoEnabled= false.

实际输出:属性设置为 True 但不隐藏按钮

预期输出:隐藏按钮

希望得到最好的答案。谢谢