Comments (6)
发布的时候 antd 还没发布 v5 ... 这两天看一下
from create-antd-modal.
发布的时候 antd 还没发布 v5 ... 这两天看一下
👌
from create-antd-modal.
这个是因为 modal 是动态创建的,不在页面的组件树上,所以获取不到各种 context 的值。
官方利用 useModal 返回 holder 是一种很好的解决办法,就是不够简洁。我尽量想想成本更低的方法
from create-antd-modal.
这个是因为 modal 是动态创建的,不在页面的组件树上,所以获取不到各种 context 的值。 官方利用 useModal 返回 holder 是一种很好的解决办法,就是不够简洁。我尽量想想成本更低的方法
好
from create-antd-modal.
抱歉这么晚解决,现在你可以使用 createFunctionWithDefaultProps
了,详情查看文档
from create-antd-modal.
v1.5.0 增加了 useModalCreation,使用更便捷
import React from 'react';
import { Button } from 'antd';
import { useModalCreation } from 'create-antd-modal';
import RootContainer from './RootContainer';
const Demo: React.FC = () => {
const [contextHolder, createModal] = useModalCreation();
return (
<RootContainer>
<Button
onClick={() => {
createModal({
title: 'Some title',
content: 'You can see that the i18n and theme configuration works now',
});
}}
>
Context Providing
</Button>
{contextHolder}
</RootContainer>
);
};
export default Demo;
from create-antd-modal.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from create-antd-modal.