NativeBase: evaluating 'this.toastInstance._root' Error when using Toast

Hi, if I use Toast of native-base in componentWillReceiveProps method it will give me an error ‘null is not an object’ (evaluating ‘this.toastInstance._root’) .

the code is : componentWillReceiveProps(){ Toast.show({ text: 'Msg here', position: 'bottom', buttonText: 'OK' }) } I guess the reason is that the life of the componentWillReceiveProps ends before the Toast , is that right ? and is there any way to slove this since I have to give the user a information after he backward from another page ? Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Please check this once with NativeBase 2.3.3

I read the docs, and I found this solution. For Toast to work, you need to wrap your topmost component inside <Root> from native-base.

<Root>
    <AppNavigator />
</Root>

Follow Docs for help, it works

@azat-co I have wrapped my Root with NativeBase root, but the issue still exists (sometimes), using the latest version of NativeBase

My solution here might help you.