英文:
How to setup a react-flowbite modal?
问题
While adding the react-flowbite modal to a react code, this error appears:
How to configure all that? How to setup a button so that it toggles the modal onClick?
Thanks
These are the imports:
import {
Button,
Checkbox,
Label,
Modal,
TextInput,
} from "flowbite-react";
This is the code:
(Couldn't paste it here because the code was more than text)
<https://flowbite-react.com/modal>
Scroll down up to "form elements"
英文:
While adding the react-flowbite modal to a react code, this error appears:
How to configure all that? How to setup a button so that it toggles the modal onClick?
Thanks
These are the imports :
import {
Button,
Checkbox,
Label,
Modal,
TextInput,
} from "flowbite-react";
This is the code:
(Couldn't paste it here because the code was more that text)
<https://flowbite-react.com/modal>
Scroll down up to "form elements"
答案1
得分: 0
使用导入的 Modal 作为您的 Modal 组件的包装器
import { Modal } from "flowbite-react";
function App() {
const [show, setShow] = useState(false);
return (
<button onClick={() => setShow(true)}>切换模态框</button>
<Modal show={show} handleClose={() => setShow(false)}>
<div>模态框内容</div>
</Modal>
);
}
英文:
use imported Modal as wrapper for your Modal component
import { Modal } from "flowbite-react";
function App() {
const [show, setShow] = useState(false)
return (
<button onClick={() => setShow(true)}>toggle modal</button>
<Modal show={show} handleClose={() => setShow(false)}>
<div>Modal Content</div>
</Modal>
)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论