crazycodeboy / react-native-easy-toast

A react native module to show toast like android, it works on iOS and Android.
http://www.devio.org/
MIT License
1.11k stars 263 forks source link

Use Toast React Hooks #82

Open AgustinNG opened 5 years ago

AgustinNG commented 5 years ago

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.

danstepanov commented 5 years ago
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;
alikrodrigues commented 5 years ago

@danstepanov thanks, i'ts work for me.

malvinder commented 4 years ago

Works for me as well. Thank you @danstepanov

yazmnh87 commented 4 years ago

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}?

huy-lv commented 3 years ago

Please add this to readme