I am using nativebase ("native-base": "^2.12.1"
) at react-native project.
I gonna use show toast on the method in react component class
assignTicket(id) {
return Toast.show({
text: "Wrong password!",
buttonText: "Okay",
duration: 3000,
type: "success"
});
}
But I am getting an error at calling this method:
undefinded is not an object (evaluating 'this.toastInstance._root')
I think this is not nativebase version issue, I am using the latest version. Thanks in advance.
For Toast to work, you need to wrap your topmost component inside <Root>
from native-base.
import Root from "native-base";
import Root from native base and wrap the whole container/view inside render's return function
render() {
return (<Root>your app-return function code</Root>);}
Import Root component from native-base and wrap the entire app in it. This worked for me after days of looking for solution. Wonder why it wasn't stated in the docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With