Code Monkey home page Code Monkey logo

Comments (3)

pavelspichonak avatar pavelspichonak commented on June 15, 2024

@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 get typescript errors:
Screen Shot 2020-12-27 at 2 33 25 AM

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.

from mui-modal-provider.

Quernest avatar Quernest commented on June 15, 2024

@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 get typescript errors:
Screen Shot 2020-12-27 at 2 33 25 AM

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.

pavelspichonak avatar pavelspichonak commented on June 15, 2024

@Quernest thanks a lot!

from mui-modal-provider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.