首页 > 解决方案 > 如何在不添加 Jsx 标签的情况下显示自定义警报

问题描述

我想在响应后显示一个自定义警报,它是来自 axios 拦截器的第三方库。但是拦截器文件没有任何用户界面,因此如何在不将其添加到渲染方法中的情况下显示我的自定义警报。

import AlertPro from "react-native-alert-pro";
// Add a response interceptor

    axiosInstance.interceptors.response.use(
      function (response) {
        // Do something with response data
        return response.data;
      },
      function (error) {
     AlertPro.open();
        // Do something with response error

     //   return Promise.reject(error);
      }
    );

我已经尝试了上面的代码,但没有工作。

标签: reactjsreact-nativealert

解决方案


推荐阅读