Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Toast React Hooks #82

Open
AgustinNG opened this issue Aug 20, 2019 · 5 comments
Open

Use Toast React Hooks #82

AgustinNG opened this issue Aug 20, 2019 · 5 comments

Comments

@AgustinNG
Copy link

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
Copy link

danstepanov commented Aug 24, 2019

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
Copy link

@danstepanov thanks, i'ts work for me.

@malvinder
Copy link

Works for me as well.
Thank you @danstepanov

@yazmnh87
Copy link

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
Copy link

huy-lv commented Dec 12, 2020

Please add this to readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants