Skip to content

Commit

Permalink
Add typings for dismissActionSheet method (#40012)
Browse files Browse the repository at this point in the history
Summary:
This pull request addresses two key issues. Firstly, it adds a missing docstring to the `dismissActionSheet` function within the `ActionSheetIOS` object. Secondly, it introduces TypeScript typings for the `dismissActionSheet` function.

## Changelog:

[iOS] [Added] - Add missing docstring to the `dismissActionSheet` function in `ActionSheetIOS`.
[iOS] [Added] - Add TypeScript typings for the `dismissActionSheet` function in `ActionSheetIOS`.

Pull Request resolved: #40012

Test Plan:
To ensure the code is solid, I followed these steps:

1. Ran Flow to verify that there were no errors.
2. Added a TypeScript test related to the `dismissActionSheet` function to ensure it's typed as expected.

Reviewed By: NickGerleman

Differential Revision: D50097458

Pulled By: arushikesarwani94

fbshipit-source-id: 63348239dfe19e3a07f94e5a7b59ae43a47c1975
  • Loading branch information
LRNZ09 authored and facebook-github-bot committed Oct 10, 2023
1 parent ea88fbe commit 89c7be8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ export interface ActionSheetIOSStatic {
failureCallback: (error: Error) => void,
successCallback: (success: boolean, method: string) => void,
) => void;

/**
* Dismisses the most upper iOS action sheet presented, if no action sheet is
* present a warning is displayed.
*/
dismissActionSheet: () => void;
}

export const ActionSheetIOS: ActionSheetIOSStatic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ const ActionSheetIOS = {
);
},

/**
* Dismisses the most upper iOS action sheet presented, if no action sheet is
* present a warning is displayed.
*/
dismissActionSheet: () => {
invariant(RCTActionSheetManager, "ActionSheetManager doesn't exist");
if (typeof RCTActionSheetManager.dismissActionSheet === 'function') {
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native/types/__typetests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2115,4 +2115,7 @@ const ActionSheetIOSTest = () => {
},
() => undefined,
);

// test dismissActionSheet method
ActionSheetIOS.dismissActionSheet();
};

0 comments on commit 89c7be8

Please sign in to comment.