对话框导致错误访问element.ref在React 19中被删除

问题描述 投票:0回答:1

我将

primereact
nextjs
一起使用,但出现错误
Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.
。所以我猜
dialog
组件正在使用一些
ref
但我不知道如何解决这个问题,该对话框包含一个表单,并且无论错误如何,该表单实际上都是有效的,可以安全地忽略它吗?

Table.js


const Table = ()=>{
  const [userDialog, setUserDialog] = useState(false);

  const openCreateUserDialog = () => {
    setUserDialog(true);
  };

  const leftToolbarTemplate = () => {
    return (
      <div className="flex flex-wrap gap-2">
        <Button
          label={t("adminTeamPage.new.title")}
          icon="pi pi-plus ml-1"
          severity="success"
          onClick={openCreateUserDialog}
        />
      </div>
    );
  };

return(
     <CreateUser userDialog={userDialog} setUserDialog={setUserDialog} />
)

}

CreateUser.js

const CreateUser = ({ userDialog, setUserDialog })=>{

return(
    <Dialog
      visible={userDialog}
      header={t("adminTeamPage.new.title")}
      modal
      onHide={() => {
        if (!userDialog) return;
        setVisible(false);
      }}
      className="p-fluid container-md px-0"
    >
      <p> some dialog content
    </Dialog>
)
}
reactjs next.js dialog primereact react-ref
1个回答
0
投票

npm install --save-dev @ant-design/v5-patch-for-react-19

© www.soinside.com 2019 - 2024. All rights reserved.