Possible un handled promise rejection: Type error: null is not an object (evaluating 'this.toastInstance_root.showToast')

Refresh

March 2019

Views

17 time

1

Am trying to add log out functionality using API call ,

  logOut = () => {
this.props.dispatch(logOut()).then(
  (response) => {
    Toast.show({
      text: response,
      position: 'bottom',
      type: 'success'
    });
  });
this.props.navigation.navigate('Home');
};

in both success and error block i am clearing the local state , but i cannot able to show the toast message in the submit function it is throwing above warning instead of toast message.what mistake i made here

  new Promise((resolve, reject) => {
  dispatch(startAuth());
  http
    .get('/api/auth/logout')
    .then((response) => {
      dispatch(authSuccess(null));
      resolve(response.message);
    })
    .catch(() => {
      dispatch(authSuccess(null));
      reject();
    });
});

0 answers