r/reactnative • u/alirezarzna • Sep 08 '20
Just published react-native-fast-toast, cross-platform Toast component for react-native
5
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.currentthen you can call
toast.show()everywhere on your app. like alertI'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
3
2
6
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
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
1
u/alirezarzna Sep 11 '20
Just released a new version, now you can change it using offset prop, see readme for example
1
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
2
2
2
2
2
u/returncoolusername Sep 09 '20
I just started working on a bare expo project, this will be very helpful, thanks for posting!
2
1
1
1
u/revcloudaimen321 Feb 03 '21
Hello Ali,
please contact me at [email protected].
We have opportunity for you.
-6
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