r/reactnative • • Sep 08 '20

Just published react-native-fast-toast, cross-platform Toast component for react-native

236 Upvotes

36 comments sorted by

10

u/alirezarzna Sep 08 '20 edited Sep 09 '20

Hi react-native developers

I just published react-native-fast-toast, cross-platform toast component for react-native

It supports stacking, success, danger, warning types and is fully customizable

I took inspiration from ant design and blueprint toast components and android native toast.

If you have any suggestions, please let me know

Here is github link

don't forget to give a star if you like it

5

u/WillBackUpWithSource Sep 08 '20

Does it work on react-native-web too?

4

u/DjWithNoNameYet Sep 08 '20

Is it possible to create this as a react hook (useToaster) or global function? So you can have a singleton high up in the app structure and you just call toastGlobal.current.show('Task finished successfully', { type: 'success' }) Then you don't need to have the <Toast/> component everywhere in your app.

5

u/alirezarzna Sep 08 '20 edited Sep 08 '20

you can do this in useEffect of your root component (onMount):

global['toast'] = toastRef.current

then you can call toast.show() everywhere on your app. like alert

I'll see if hooks can be used as an alternative.

2

u/JoeyBurrow Nov 21 '20

Hey thanks for the awesome library. I was wondering if i have a toast globally, is there a way I could then call a function toast.show within some redux code? (maybe a thunk or a saga)

Thanks!

1

u/alirezarzna Nov 21 '20

Yes, this method allow you to do that, you can call it anywhere

the global example in readme has simpler implementation and typescript support as well.

1

u/lucbas Sep 09 '20

Thanks!

Maybe include it in the README?

1

u/alirezarzna Sep 09 '20

Just included it, I might add it to the library internal, and make it default way of using the library, how does that sound?

1

u/alirezarzna Sep 30 '20

I've just added hook support, check readme for details.

3

u/rkh4n Sep 09 '20

Great! Will replace my custom toast with this. How’s expo support?

3

u/alirezarzna Sep 09 '20

Thanks! The example app in repo is expo

2

u/drewjamesandre Sep 09 '20

Do the animations run on the native thread?

6

u/Jeffdud3 Sep 09 '20

Danger toast! 🥵🍞⚠️

5

u/ahartzog Sep 08 '20

I’ll check it out! I’ve been using the Toasts by Native Base forever but I’d love to use something more standalone and customizable.

1

u/uuutttnnnkk Sep 10 '20

Can we get an example with javascript also?

1

u/alirezarzna Sep 10 '20

All examples should work on javascript too.

1

u/uuutttnnnkk Sep 10 '20

Beginner question: When I wrote,

const toastRef = useRef<Toast>(null);

like in the example on Github, it says "Type arguments can only be used in TypeScript files."

1

u/alirezarzna Sep 10 '20

Use the example in readme instead.

1

u/me1kkkk Sep 10 '20

It works awesome. I use it in my App now. Can i switch the Position a bit more to the bottom anyhow?

1

u/alirezarzna Sep 10 '20

Thanks! I'm working on a prop for that

1

u/alirezarzna Sep 11 '20

Just released a new version, now you can change it using offset prop, see readme for example

1

u/me1kkkk Sep 16 '20

Awesome! Thank you :) Great work

3

u/DjWithNoNameYet Sep 08 '20

Thanks so much! This is exactly what my app is lacking. I couldn't find one for web/iOS/android.

2

u/soitrang Sep 09 '20

I've tried to build one but not good as yours, will try it soon, thanks.

2

u/Chawki_ Android Sep 09 '20

What I currently needed

2

u/saghul Sep 09 '20

Looks really nice, kudos!

2

u/rateb_ Sep 09 '20

I was gonna make this myself thanks it looks great.

2

u/AcetyldFN Sep 09 '20

Love it. Gonna use it

2

u/returncoolusername Sep 09 '20

I just started working on a bare expo project, this will be very helpful, thanks for posting!

2

u/LavishCode Sep 14 '20

That's really cool!

1

u/AcetyldFN Sep 10 '20

love it!

But somehow its at the buttom: https://prnt.sc/uf5gn9

1

u/rjvmcv Oct 07 '20

Had this saved for a while, finally got to use it. It's really good. Thank you!

1

u/revcloudaimen321 Feb 03 '21

Hello Ali,

please contact me at [email protected].
We have opportunity for you.

-6

u/cybermage Sep 08 '20

“Toast” is dumb. Way dumber than “cookie”