Skip to content

feat: Improved types for react useIonModal #28680

Closed
Closed

Description

@aeharding

Prerequisites

Describe the Feature Request

useIonModal should type props parameter.

Describe the Use Case

useIonModal currently allows any for component props. This is dangerous and has caused many crashes and unintended behaviors in my experience.

Currently:

export declare function useIonModal(component: ReactComponentOrElement, componentProps?: any): UseIonModalResult;

Describe Preferred Solution

export declare function useIonModal<P>(component: React.ComponentClass<P> | React.FC<P>, componentProps?: P): UseIonModalResult;
export declare function useIonModal(component: React.ReactElement, componentProps?: any): UseIonModalResult;

Describe Alternatives

Leaving as-is

Related Code

No response

Additional Information

If you would accept this change, I would happily make a PR

Activity

  1. aeharding commented on Dec 11, 2023

    @aeharding
    ContributorAuthor

    FYI I see #27548, this seemed a bit more open-ended so I decided to make a separate issue in smaller scope (fixing the types).

  2. changed the title [-]feat: Improved types for useIonModal[/-] [+]feat: Improved types for react useIonModal[/+] on Dec 11, 2023
  3. liamdebeasi commented on Dec 11, 2023

    @liamdebeasi
    Contributor

    Thanks! I think this would be a good change to make. We'll want to do make this change for both useIonModal and useIonPopover, and T should continue to be any if not set to avoid breaking changes.

  4. added
    needs: reply
    on Dec 11, 2023
  5. aeharding commented on Dec 11, 2023

    @aeharding
    ContributorAuthor

    @liamdebeasi, in my testing Typescript automatically infers T based on the component you pass it. By making the proposed change I was able to see type errors with incorrect params in my usage without adding any explicit generic declarations to my code :)

  6. added and removed
    needs: reply
    on Dec 11, 2023
  7. liamdebeasi commented on Dec 11, 2023

    @liamdebeasi
    Contributor

    in my testing Typescript automatically infers T based on the component you pass it.

    I'm aware, I was just clarifying that we shouldn't default it to anything else 😄

  8. added
    help wanted
    type: feature request
    package: core
    on Jan 9, 2024
  9. ionitron-bot commented on Jan 9, 2024

    @ionitron-bot

    This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

    If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

    For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

    Thank you!

  10. added
    package: react
    and removed
    package: core
    on Jan 9, 2024
  11. mikelhamer commented on Jul 23, 2024

    @mikelhamer
    Contributor

    Is this still relevant?

  12. aeharding commented on Jul 23, 2024

    @aeharding
    ContributorAuthor

    Yes, and my PR was close to being merged, but @liamdebeasi left Ionic so no progress since

  13. mikelhamer commented on Jul 23, 2024

    @mikelhamer
    Contributor

    Ah, thank you. I'm new here and digging around for ways to help. So your PR partially completed the feature, but there is some left to do?

  14. added a commit that references this issue on Aug 18, 2026
    cebd101
  15. ionitron-bot commented on Sep 18, 2026

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  16. locked and limited conversation to collaborators on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedpackage: reacttype: feature request

    Fields

    Stage

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions