为什么imported hook报错已经声明了

Why imported hook gives an error has already been declared

在我的 React 项目中,我导入了这个:

import confirmDialog from '../../components/confirmDialog/ConfirmDialog';

当我添加底线时:

const [confirmDialog, SetConfirmDialog] = useState ({isOpen: false, title: '', subTitle: ''});

我收到以下错误: Identifier 'confirmDialog' has already been declared.

我也像这样在 MyComponet 中使用 confirmDialog:

<ConfirmDialog
        ConfirmDialog={confirmDialog}
        SetConfirmDialog={SetConfirmDialog}
      />

您正在重新声明导入的组件。 您可以通过编辑变量的名称来解决此问题

import ConfirmDialog from '../../components/confirmDialog/ConfirmDialog';
...

const [confirmDialogContent, SetConfirmDialogContent] = useState ({isOpen: false, title: '', subTitle: ''});

...

<ConfirmDialog
        ConfirmDialog={confirmDialogContent}
        SetConfirmDialog={SetConfirmDialogContent}
      />