Comments (3)
@Quernest I'd like to thank you. I've not checked how it works now but you have added this feature so fast. Thanks a lot!
And I'd like to say that I like and enjoy your code.
I'm not sure if it is good to ask it here but I hope you do not mind:
- Using latest 4 version of material-ui with latest version of typescript I have modal window types like this:
import { ReactNode } from 'react';
import { DialogProps } from '@material-ui/core/Dialog';
export interface IProps extends DialogProps {}
and I have to update types like this:
import { ReactNode } from 'react';
import { DialogProps } from '@material-ui/core/Dialog';
export interface IProps extends DialogProps {
onClose: () => void;
onExited: () => void;
}
Is it your package typings issue or not?
- now I can pass any props to
showModal
method.
Is it possible to update typings to be able to pass only that props which passed modal component supports?
For example if I use showModal like this:
showModal(Modal, modalPropsObject);
I'd like to be able to pass only that props which Modal component declared in its typings for typescript?
P.S. I see you are from Ukraine. Maybe it is possible somehow to contact you? I'm from Belarus and if you do not mind it would be great to discuss these questions if you have time. Thanks a lot.
from mui-modal-provider.
@Quernest I'd like to thank you. I've not checked how it works now but you have added this feature so fast. Thanks a lot!
And I'd like to say that I like and enjoy your code.I'm not sure if it is good to ask it here but I hope you do not mind:
1. Using latest 4 version of material-ui with latest version of typescript I have modal window types like this:
import { ReactNode } from 'react'; import { DialogProps } from '@material-ui/core/Dialog'; export interface IProps extends DialogProps {}
and I have to update types like this:
import { ReactNode } from 'react'; import { DialogProps } from '@material-ui/core/Dialog'; export interface IProps extends DialogProps { onClose: () => void; onExited: () => void; }
Is it your package typings issue or not?
1. now I can pass any props to `showModal` method. Is it possible to update typings to be able to pass only that props which passed modal component supports?
For example if I use showModal like this:
showModal(Modal, modalPropsObject);
I'd like to be able to pass only that props which Modal component declared in its typings for typescript?
P.S. I see you are from Ukraine. Maybe it is possible somehow to contact you? I'm from Belarus and if you do not mind it would be great to discuss these questions if you have time. Thanks a lot.
Thank you for your comment. I am glad that this package is useful to you 🙂
You have this error because the DialogProps
don't have the same types as the IProps
fields in the library. Especially onClose
and onExited
fields conflicts with it.
interface IProps {
// ...
onClose?: () => void;
onExited?: () => void;
// ...
}
To fix this issue, I will remove this fields from the IProps
interface and you can extend the DialogProps
.
But remember that the open
prop is required for the DialogProps
interface and optional for IProps
. If you are going to use the DialogProps
interface this prop will have to be passed in the initial props in showModal
or updateModal
/ modal.update
to avoid errors / warnings from typescript. But in any case this property will be set automatically when showModal
is called.
Regarding the strict typing of props for a component - I think it might be possible to use Generics. I will create a ticket for a future update.
from mui-modal-provider.
@Quernest thanks a lot!
from mui-modal-provider.
Related Issues (20)
- peerDeps issues HOT 1
- "Cannot read property 'props' of undefined" error if component unmounts before onClose is called HOT 1
- Nested dialog bug HOT 1
- Unhandled missed modal ID scenario
- MUI Dialog API changed HOT 2
- 🐛 Missing 'dist/modal.esm.js' in package HOT 2
- hideModal() from within Dialog component HOT 6
- Rerenders all components HOT 4
- Missing export for typescript types
- Support with React 18 HOT 1
- disableBackdropClick HOT 2
- Rendering a lazy-loaded dialog? HOT 2
- Do not destroy modal on component unmount HOT 5
- useModal is not a function HOT 2
- destroy is always called regardless of options. HOT 2
- How to close current modal and open another modal in parallel? HOT 4
- Throw an error in case Provider not being used HOT 19
- Make it possible to disable provider check errors
- Disable closing on backdrop click HOT 2
- Backdrop click HOT 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 mui-modal-provider.