Warning: [antd: Modal] Static function can not consume context like dynamic theme. Please use 'App' component instead.

react 的model.confirm报错,它意味着你在使用动态主题(Dynamic Theme)时不能在静态函数中使用上下文,需要使用contextHolder


const [modal, contextHolder] = Modal.useModal();

React.useEffect(() => {
  modal.confirm({
    // ...
  });
}, []);

return <div>{contextHolder}</div>;

 

posted @ 2024-01-03 10:40  风花一世月  阅读(1523)  评论(0)    收藏  举报