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

Undefined is not an object (evaluating '_this.refs.toast.show)

Open SirPhemmiey opened this issue 7 years ago • 5 comments

Hey guys, i stumbled on this problem even after confirming the import of the module in my project, Any way forward please?

SirPhemmiey avatar Apr 06 '18 20:04 SirPhemmiey

Try

this.toastRef.show('Hello!');

and set the ref with:

<Toast
    ref={ref => {
        this.toastRef = ref;
    }}
    ...
/>

xeroxoid avatar Apr 28 '18 22:04 xeroxoid

@xeroxoid , i met the same error, have tried the method u mentioned, but not work and new error given: null is not an object(evaluating '_this.toastRef.show')

blogdaren avatar May 27 '18 03:05 blogdaren

I tried this and it works:

<Toast
  ref={toast => {
    this.toast = toast;
  }}
/>

and then do

  this.toast.show(`${error.message}`);

Let me know if it works.

vikrantnegi avatar May 29 '18 12:05 vikrantnegi

I tried this and it's work for me:

Define in constructor this.toast = null

set the ref <Toast ref={ref => { this.toast = ref; }} />

and then this.toast.show(${error.message});

Maybe it could work for you!

yogeshJB avatar Nov 01 '18 08:11 yogeshJB

@vikrantnegi thanks! Working perfectly!

Bobur-kobilov avatar Feb 17 '19 10:02 Bobur-kobilov