react-native-easy-toast
react-native-easy-toast copied to clipboard
Use Toast React Hooks
The toast will not work with the new version of React Native, who is working with Hooks, the ref of the toast does not you can add the useRef.
import React, { useRef } from 'react';
import { Button, View } from 'react-native';
import Toast from 'react-native-easy-toast';
const App = () => {
const toastRef = useRef();
return (
<View style={styles.container}>
<Button title="Show Toast" onPress={() => toastRef.current.show('hello world!')} />
<Toast ref={toastRef} />
</View>
);
};
export default App;
@danstepanov thanks, i'ts work for me.
Works for me as well. Thank you @danstepanov
So if I import "DURATION" like import Toast, {DURATION} from 'react-native-easy-toast'; ref.current is undefined.
if I import Toast like import Toast from 'react-native-easy-toast'; the ref is defined, but then how do I access {DURATION}?
Please add this to readme