react-native-easy-toast icon indicating copy to clipboard operation
react-native-easy-toast copied to clipboard

Use Toast React Hooks

Open AgustinNG opened this issue 6 years ago • 5 comments

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.

AgustinNG avatar Aug 20 '19 13:08 AgustinNG

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 avatar Aug 24 '19 23:08 danstepanov

@danstepanov thanks, i'ts work for me.

alikrodrigues avatar Nov 07 '19 01:11 alikrodrigues

Works for me as well. Thank you @danstepanov

malvinder avatar Mar 30 '20 18:03 malvinder

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

yazmnh87 avatar Aug 18 '20 14:08 yazmnh87

Please add this to readme

huy-lv avatar Dec 12 '20 04:12 huy-lv