schiehll / react-alert

alerts for React
MIT License
607 stars 99 forks source link

Custom alert type with typescript #176

Open yerlantemir opened 3 years ago

yerlantemir commented 3 years ago

How to repeat example from #121 with typescript ? I am facing error:

TS2345: Argument of type '{ CUSTOM_TYPE: string; }' is not assignable to parameter of type 'AlertCustomOptionsWithType'.

yerlantemir commented 3 years ago

I came up on creating my custom useAlert hook with showAlert method which similarly takes message and type as arguments. And if type === Warning, I add '_' to my message and call alert.show method from library image

And in my AlertTemplate I do this: image

Where: image

I know that it's kinda weird solution, but it works ! :)