reactjs - 博览会和发布 channel ...如何识别开发/产品和真实 channel

标签 reactjs react-native expo

我在博览会发布 channel 方面遇到了一些问题。 我不是 React Native 和 Expo 方面的专家,这使得事情变得更容易:

如果我使用本地开发环境,则不会设置 channel (这是有道理的)。

但最终版本或“制作”也不会设置 channel , 这让我很不清楚应该如何识别“生产”和“开发”。

如果我想添加一个 channel ...例如“staging”,那么就会添加一个新的复杂级别,它将有一个 channel ...

锦上添花的是,在我的部署系统(Circle)中,我必须在 channel 中构建“开发”(否则 NODE_ENV 将是“生产”)

有人知道如何正确使用 channel 吗? :)

基本上,我没有找到比这个更好的解决方案:

import { Constants } from 'expo'
const ENV= {production:{},staging:{},development:{}}

// Having fun with channels
const channel = Constants.manifest.releaseChannel;
if (channel === null || channel === undefined || channel === '') {
  if (process.env.NODE_ENV === 'production') {
    return ENV.production;
  }
  if (process.env.NODE_ENV === 'development') {
    return ENV.development;
  }
}
if (channel === 'staging') {
  return ENV.staging;
}
if (channel === 'development') {
  return ENV.development;
}
return ENV.production;

非常感谢!

最佳答案

我认为您没有明白发布 channel 的用途。

当您的应用程序是使用 exp build 构建时它绑定(bind)到一个发布 channel (默认为default)。 稍后,如果您想进行 OTA 更新,只需运行 exp publish这将在发布 channel 上发布您的代码(同样:default默认)。

当您向用户发布独立版本时,您不希望通过 OTA 向他们提供未经测试的代码等,因此您希望用户将发布 channel 设置为 ex。 prod .

这与 NODE_ENV 完全分开,我真的不认为将它们联系起来有什么意义。

关于reactjs - 博览会和发布 channel ...如何识别开发/产品和真实 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52157012/

相关文章:

react-native - 有没有办法使用 Expo React Native 检测图像中的文本?

javascript - NextJS 在生产构建中错误的 CSS 顺序

reactjs - 如何修复 React Native 中的 Firebase/firestore 错误?

javascript - 我不明白如何使用它或它的作用,来自带有屏幕的 React Native Expo 默认项目的 _loadResourcesAsync

javascript - 如何将现有的非 React-Native-Component JS 导入/需要到 React Native 组件

javascript - 我可以用 React Native 组件做轮播吗?

ios - 如何在电子邮件中将 iOS 应用的深层链接显示为链接

javascript - 警告 : setState(. ..) : Can only update a mounted or mounting component. 这通常意味着

reactjs - ReactJS 有什么方法可以发送 HTTP 请求吗?

google-chrome-devtools - 如何在控制台中检查 react 元素的 Prop 和状态?