gunnartorfis / sonner-native

An opinionated toast component for React Native. A port of @emilkowalski's sonner.
https://gunnartorfis.github.io/sonner-native
MIT License
459 stars 18 forks source link

[BUG] toast.promise error callback #106

Closed michaelpomogajko closed 1 month ago

michaelpomogajko commented 1 month ago

Describe the bug In original sonner, the error callback of a promise can also take a function with the rejected error as parameter.

To Reproduce

toast.promise(
  new Promise((resolve, reject) => {
    setTimeout(() => {
      reject(new Error('Nah'));
   }, 1000);
  }),
  {
    loading: 'Loading..',
    success: (result: string) => `Resolved:  ${result}`,
    error: (error: Error) => `Rejected: ${error.message}`,
  }

Expected behavior Types should allow this, as well as functionality should mimic original sonner

Environment info

Library Version
sonner-native latest
react-native latest
react-native-reanimated latest
react-native-gesture-handler latest
bpingris commented 1 month ago

hello! i've opened a PR that should cover that feature

gunnartorfis commented 1 month ago

Releasing the fix in an hour or so, closed