reactjs - 如何在不添加 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);
}
);
我已经尝试了上面的代码,但没有工作。
解决方案
推荐阅读
- amazon-web-services - 单个 ECS 集群中的 AWS 多个扩展组
- swift - Xcode 12 + SwiftUI 列表:点击粘贴时列表行叠加
- python - 如何使扭曲的延迟操作列表真正异步
- c - 获取传递给 C 中函数的变量名
- postgresql - 允许架构中所有表的“SELECT”权限,包括由不同用户创建的新表(AWS RDS;PostgreSQL 11)
- android - 加载 8000px png drawable Android Scrollable Image
- php - “不支持您的文件类型”错误与 PHP 代码
- java - Tomcat 9 通用类加载器是 URLClassLoader 吗?
- javascript - 如何在 javascript/jquery 中显示相对于视口而不是网页的弹出元素?
- pandas - 熊猫转轴?数据透视表?熔化?堆叠还是取消堆叠?