ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.42k stars 119 forks source link

(Suggestion) improve SheetManager with better typing #297

Closed prs-wjy closed 5 months ago

prs-wjy commented 1 year ago

I'm currently using this library with the SheetManager in typescript, but i found it's typing can be improved. these are the things that i think can be improved:

  1. you can put any string to id parameter in the show function, it should not, it should only accept registered id.
  2. the payload type in options should depends on the payload of the sheet component that registered with the given id, not just by defining generic on the show function.
  3. it just feel weird and "disconnected" when you need to import registerSheet to register a sheet, but use SheetManager to show and hide it.

So i already creating a solution for all of those problem, which you can see here (https://gist.github.com/prs-wjy/d92e44e026b0f93c95cae0e0d0e913df).

The only thing that i also want to improve is to make the payload parameter in the show function become required if only the sheet component with the id argument have required parameter on it's payload, but i don't know how to do it (i don't even know if it's possible 😅)

I want to make a pull request to make it the default behavior, but i never contribute to a library code nor any open source code, so i think it's just better for me to create this issue.

What do you guys think?