fascinating-indigo•3y ago
Passing Component Props
How can I pass props to my modal created with useModal from my Mantine <Button> component?
9 Replies
Hi @theswarm420. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You can pass props to your modal created with
useModal from your Mantine <Button> component by using the show function returned by useModal in the onClick handler of your <Button> component. Here's an example based on the information provided in the extracts:
In this example, the show function is used to control the visibility of the modal. When the button is clicked, the show function is called, which triggers the opening of the modal. The modalProps are then passed to the <Modal> component to control its behavior and appearance.
For more information, you can refer to the useModal documentation (https://refine.dev/docs/api-reference/antd/hooks/ui/useModal).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1117289843584671775> kapa.ai is still learning and improving, please let us how it did by reacting below
fascinating-indigoOP•3y ago
@kapa.ai I'm implementing useModal from Refine's core hooks, not antd. Is there a way to pass modal props with this hook?
Let me check the knowledge base for you. One moment! :books:
----------------------
The
useModal hook from Refine's core hooks does not directly provide a way to pass modal props. This hook is designed to be headless and UI-independent, and it only returns the show and close functions, and the visible state. Here's an example of how it's used:
In this example, the visible state is used to show or hide the modal. The show and close functions allow changing the visible state. It does not provide any functionality besides this. You can use this hook anywhere.
For more information, you can refer to the useModal documentation (https://refine.dev/docs/api-reference/core/hooks/ui/useModal).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1117289843584671775> kapa.ai is still learning and improving, please let us how it did by reacting below
fascinating-indigoOP•3y ago
@kapa.ai How can I instead pass props into Mantine's
useForm?Let me check the knowledge base for you. One moment! :books:
----------------------
You can pass props into Mantine's
useForm by providing an object to the useForm hook. This object can contain initial values for the form fields, validation rules, and other properties. Here's an example based on the information provided in the extracts:
In this example, initialValues is an object that contains the initial values for the form fields. validate is an object that contains validation rules for the form fields. The useForm hook returns an object that contains various properties and methods that you can use to manage your form.
For more information, you can refer to the useForm documentation (https://refine.dev/docs/api-reference/mantine/hooks/form/useForm).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1117289843584671775> kapa.ai is still learning and improving, please let us how it did by reacting below
optimistic-gold•3y ago
It's seems basic react question 🤔 Sorry If i could not understand question exactly.
you can check this example https://react.dev/learn/sharing-state-between-components#lifting-state-up-by-example
If this not answer yok question please provide reproducible example on codesandbox, i can try to help