typescript - 为 react-native-config 配置声明模块?
问题描述
我有一个旧的项目配置环境,react-native-dotenv
就像 beblow
declare module 'react-native-dotenv' {
export const APP_ROOT_API: string;
export const APP_PUBLIC_AVATAR_PATH: string;
export const APP_ABOUT_URL: string;
export const APP_ONESIGNAL_APP_ID: string;
export const APP_ONESIGNAL_PREFIX: string;
export const APP_TEST_USER_ID: string;
export const APP_TEST_TOKEN: string;
export const APP_TEST_REFRESH_TOKEN: string;
export const CLIENT_ID: string;
export const CLIENT_SECRET: string;
export const REDIRECT_URL: string;
export const AUTHORIZATION_ENDPOINT: string;
export const TOKEN_ENDPOINT: string;
export const SCOPES;
export const ENV;
}
但是现在我想通过使用来更改配置环境react-native-config
我可以像这样更改代码吗:
declare module 'react-native-config' {
export const APP_ROOT_API: string;
export const APP_PUBLIC_AVATAR_PATH: string;
export const APP_ABOUT_URL: string;
export const APP_ONESIGNAL_APP_ID: string;
export const APP_ONESIGNAL_PREFIX: string;
export const APP_TEST_USER_ID: string;
export const APP_TEST_TOKEN: string;
export const APP_TEST_REFRESH_TOKEN: string;
export const CLIENT_ID: string;
export const CLIENT_SECRET: string;
export const REDIRECT_URL: string;
export const AUTHORIZATION_ENDPOINT: string;
export const TOKEN_ENDPOINT: string;
export const SCOPES;
export const ENV;
}
解决方案
native-dotenv maintainer here.
react-native-config` 需要更多的时间来设置链接和其他东西。这些也是来自 .env 文件吗?
推荐阅读
- python - 使用 pandas 的 txt 中的 CSV 文件
- r - ggplot2:防止 geom_bar 按字母顺序排列,并且 y 刻度不显示中断
- r - 将两个数据帧除以R中的公共行
- javascript - 使用外部 API 进行身份验证
- mysql - 想比较两个Mysql表中的文本
- angular - Angular 4 Jasmine 测试监视属性以将不同的值返回给不同的测试
- javascript - 从内存中存储和检索数据是否比使用数据属性和 jQuery 从 DOM 中存储和检索数据更快?
- python - 散景极地投影
- ruby-on-rails - Rails 无需离开控制台即可更新模型设置
- javascript - React hooks:使用 useEffect 时未获取状态更新