首页指南参考教程

升级 Expo SDK

了解如何增量升级项目中的 Expo SDK 版本。


我们建议逐步升级 SDK 版本,一次一个。这样做将帮助你查明升级过程中出现的损坏和问题。

随着新 SDK 的发布,最新版本将进入当前发布状态。这适用于 Expo Go,因为它仅支持最新的 SDK 版本,并且不再支持以前的版本。我们建议将 开发构建 用于生产应用,因为 EAS 服务上旧 SDK 版本的向后兼容性往往会更长,但不会永远持续下去。

¥With a new SDK release, the latest version enters the current release status. This applies to Expo Go as it only supports the latest SDK version and previous versions are no longer supported. We recommend using development builds for production apps as the backwards compatibility for older SDK versions on EAS services tends to be much longer, but not forever.

如果你希望安装特定版本的 Expo Go,请访问 expo.dev/go。它支持 Android 设备/模拟器和 iOS 模拟器的下载。但是,由于 iOS 平台限制,只有最新版本的 Expo Go 可用于在物理 iOS 设备上安装。

¥If you are looking to install a specific version of Expo Go, visit expo.dev/go. It supports downloads for Android devices/emulators and iOS simulators. However, due to iOS platform restrictions, only the latest version of Expo Go is available for installation on physical iOS devices.

如何升级到最新的 SDK 版本

¥How to upgrade to the latest SDK version

1

升级 Expo SDK

¥Upgrade the Expo SDK

安装新版本的 Expo 包:

¥Install the new version of the Expo package:

Terminal
# Install latest
npm install expo@latest

# Install a specific SDK version (for example, SDK 51)
npm install expo@51
Terminal
# Install latest
yarn add expo@latest

# Install a specific SDK version (for example, SDK 51)
yarn add expo@51

2

升级依赖

¥Upgrade dependencies

升级所有依赖以匹配已安装的 SDK 版本。

¥Upgrade all dependencies to match the installed SDK version.

Terminal
npx expo install --fix

3

请遵循发行说明以获取任何其他说明

¥Follow the release notes for any other instructions

阅读 SDK 变更日志 了解你要升级到的 SDK 版本。它们包含有关重大更改、弃用以及可能影响你的应用的其他更改的重要信息。

¥Read the SDK changelogs for the SDK version you are upgrading to. They contain important information about breaking changes, deprecations, and other changes that may affect your app.

升级原生项目

¥Upgrade native projects

如果你管理自己的原生项目,则需要手动将任何更改应用到原生 android 和 ios 项目目录。我们的 原生项目升级助手 将向你展示一个差异,描述你需要进行的更改。或者,你可以考虑 采用预构建,以便将来更轻松地升级。

¥If you manage your own native projects, you will need to manually apply any changes to your native android and ios project directories. Our native project upgrade helper will show you a diff that describes the changes you need to make. Alternatively, you could consider adopting prebuild for easier upgrades in the future.

SDK 变更日志

¥SDK Changelogs

每个 SDK 公告博客文章都包含弃用、重大更改以及该特定 SDK 版本可能特有的任何其他内容。升级时,请务必检查这些内容,以确保不会遗漏任何内容。

¥Each SDK announcement blog post contains deprecations, breaking changes, and anything else that might be unique to that particular SDK version. When upgrading, be sure to check these out to make sure you don't miss anything.

SDK 51

博客文章

¥Blog post

SDK 50

博客文章

¥Blog Post

已弃用的 SDK 版本变更日志

¥Deprecated SDK Version Changelogs

SDK 49

博客文章

¥Blog Post

SDK 48

博客文章

¥Blog Post

SDK 47

博客文章

¥Blog Post

SDK 46

博客文章

¥Blog Post

SDK 45

博客文章

¥Blog Post

SDK 44

博客文章

¥Blog Post

SDK 43

博客文章

¥Blog Post

SDK 42

博客文章

¥Blog Post

SDK 41

博客文章

¥Blog Post

SDK 40

博客文章

¥Blog Post

SDK 39

博客文章

¥Blog Post

SDK 38

博客文章

¥Blog Post

SDK 37

博客文章

¥Blog Post

SDK 36

博客文章

¥Blog Post

SDK 35

博客文章

¥Blog Post

从 SDK 34 升级

¥Upgrade from SDK 34

  • 运行 expo update 35.0.0

    ¥Run expo update 35.0.0

注意

¥Notes

  • 此版本有一些小的重大 API 更改。完整列表请参见 changelog

    ¥There are a few small breaking API changes with this release. See the changelog for the full list.

SDK 34

博客文章

¥Blog Post

从 SDK 33 升级

¥Upgrade from SDK 33

  • 运行 expo update 34.0.0

    ¥Run expo update 34.0.0

注意

¥Notes

  • 你将需要更新导入以匹配新的模块化格式。例如,如果你当前有 import { FileSystem } from 'expo';,则需要运行 npx expo install expo-file-system,然后将导入更改为 import * as FileSystem from 'expo-file-system';。我们提供了 codemod 来帮助自动化此操作。

    ¥You will need to update your imports to match the new modular format. For example, if you currently have import { FileSystem } from 'expo';, you will need to run npx expo install expo-file-system and then change your import to import * as FileSystem from 'expo-file-system';. We provide a codemod to help automate this.

  • 此版本有一些小的重大 API 更改。完整列表请参见 changelog

    ¥There are a few small breaking API changes with this release. See the changelog for the full list.

SDK 33

博客文章

¥Blog Post

从 SDK 32 升级

¥Upgrade from SDK 32

  • app.json,将 sdkVersion 更改为 "33.0.0"

    ¥app.json, change sdkVersion to "33.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

{
  "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
  "expo": "^33.0.0",
  "react": "16.8.3"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • 你将需要更新导入以匹配新的模块化格式。例如,如果你当前有 import { FileSystem } from 'expo';,则需要运行 npx expo install expo-file-system,然后将导入更改为 import * as FileSystem from 'expo-file-system';。我们提供了 codemod 来帮助自动化此操作。

    ¥You will need to update your imports to match the new modular format. For example, if you currently have import { FileSystem } from 'expo';, you will need to run npx expo install expo-file-system and then change your import to import * as FileSystem from 'expo-file-system';. We provide a codemod to help automate this.

  • 此版本有一些小的重大 API 更改。完整列表请参见 changelog

    ¥There are several small breaking API changes with this release. See the changelog for the full list.

SDK 32

博客文章

¥Blog Post

从 SDK 31 升级

¥Upgrade from SDK 31

  • app.json,将 sdkVersion 更改为 "32.0.0"

    ¥app.json, change sdkVersion to "32.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
  "expo": "^32.0.0",
  "react": "16.5.0"
}
  • 如果使用默认的 .babelrc,请将其更改为 babel.config.js:

    ¥If using the default .babelrc, change it to babel.config.js:

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • 此版本有一些小的重大 API 更改。完整列表请参见 changelog

    ¥There are several small breaking API changes with this release. See the changelog for the full list.

SDK 31

博客文章

¥Blog Post

从 SDK 30 升级

¥Upgrade from SDK 30

  • app.json,将 sdkVersion 更改为 "31.0.0"

    ¥app.json, change sdkVersion to "31.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
  "expo": "^31.0.0",
  "react": "16.5.0"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • 此版本有一些小的重大 API 更改。完整列表请参见 changelog

    ¥There are several small breaking API changes with this release. See the changelog for the full list.

SDK 30

博客文章

¥Blog Post

从 SDK 29 升级

¥Upgrade from SDK 29

  • app.json,将 sdkVersion 更改为 "30.0.0"

    ¥app.json, change sdkVersion to "30.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
  "expo": "^30.0.0",
  "react": "16.3.1"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • Fingerprint 已更名为 LocalAuthentication

    ¥Fingerprint has been renamed to LocalAuthentication

SDK 29

博客文章

¥Blog Post

从 SDK 28 升级

¥Upgrade from SDK 28

  • app.json,将 sdkVersion 更改为 "29.0.0"

    ¥app.json, change sdkVersion to "29.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
  "expo": "^29.0.0",
  "react": "16.3.1"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • Contacts 中的一些字段名称已更改。请参阅 documentation 了解更多信息。

    ¥Some field names in Contacts were changed. See the documentation for more information.

SDK 28

博客文章

¥Blog Post

从 SDK 27 升级

¥Upgrade from SDK 27

  • app.json,将 sdkVersion 更改为 "28.0.0"

    ¥app.json, change sdkVersion to "28.0.0",

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz",
  "expo": "^28.0.0",
  "react": "16.3.1"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • 所有 SDK 版本上的 Android 应用现在都需要通知渠道来发送通知。即使你尚未使用 SDK 28,这也可能会影响你。阅读这篇博文 了解所有必要的信息。

    ¥Android apps on all SDK versions now require notification channels for push notifications. This may impact you even if you don't yet use SDK 28. Read this blog post for all of the necessary information.

  • Android 应用图标现在被强制转换为自适应图标。请务必测试你的应用图标,并在需要时提供自适应图标。阅读这篇博文 了解所有必要的信息。

    ¥Android app icons are now coerced into adaptive icons. Be sure to test your app icon and supply an adaptive icon if needed. Read this blog post for all of the necessary information.

  • 印刷品已移出 DangerZone;相应地更新你的导入。

    ¥Print has been moved out of DangerZone; update your imports accordingly.

SDK 27

博客文章

¥Blog Post

从 SDK 26 升级

¥Upgrade from SDK 26

  • 在 app.json 中,将 sdkVersion 更改为 "27.0.0"

    ¥In app.json, change sdkVersion to "27.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-27.0.0.tar.gz",
  "expo": "^27.0.0",
  "react": "16.3.1"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • View.propTypes 已从 React Native 中删除,因此如果你的代码(或任何依赖库)使用它,就会中断。请改用 ViewPropTypes。我们强烈建议你在禁用 dev 标志的情况下运行你的应用,以测试它是否受到此更改的影响。

    ¥View.propTypes has been removed from React Native, so if your code (or any of your dependent libraries) uses it, that will break. Use ViewPropTypes instead. We strongly recommend running your app with the dev flag disabled to test whether it's affected by this change.

  • 我们更改了 Constants.linkingUri 的格式(请参阅上面的链接更改),因此如果你的代码对此做出假设,你应该仔细检查。

    ¥We changed the format of Constants.linkingUri (see Linking changes above), so if your code makes assumptions about this, you should double check that.

  • 相机胶卷权限 现在需要使用 ImagePicker.launchCameraAsync() 和 ImagePicker.launchImageLibraryAsync()。你可以致电 Permissions.askAsync(Permissions.CAMERA_ROLL) 索取。

    ¥Camera roll permissions are now required to use ImagePicker.launchCameraAsync() and ImagePicker.launchImageLibraryAsync(). You can ask for them by calling Permissions.askAsync(Permissions.CAMERA_ROLL).

SDK 26

博客文章

¥Blog Post

从 SDK 25 升级

¥Upgrade from SDK 25

  • 在 app.json 中,将 sdkVersion 更改为 "26.0.0"

    ¥In app.json, change sdkVersion to "26.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz",
  "expo": "^26.0.0",
  "react": "16.3.0-alpha.1"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • Expo.Util 已弃用,功能已移至 Expo.DangerZone.LocalizationExpo.Updates

    ¥Expo.Util is deprecated, functionality has been moved out to Expo.DangerZone.Localization and Expo.Updates.

  • ios.loadJSInBackgroundExperimental 现已弃用,请改用新的 Updates API。此配置的等效项是 updates.fallbackToCacheTimeout: 0

    ¥ios.loadJSInBackgroundExperimental is now deprecated, use the new Updates API instead. The equivalent of this configuration is updates.fallbackToCacheTimeout: 0.

  • isRemoteJSEnabled 也已弃用,请使用 updates.enabled 代替。

    ¥isRemoteJSEnabled is also deprecated, use updates.enabled instead.

  • React Native 0.54 依赖于 React 16.3.0-alpha.1。React 16.3 弃用了 componentWillMountcomponentWillReceivePropscomponentWillUpdate 的使用。这些已被静态生命周期方法取代:getDerivedStateFromPropsgetSnapshotBeforeUpdate,但 16.3.0-alpha.1 中仅提供 getDerivedStateFromProps

    ¥React Native 0.54 depends on React 16.3.0-alpha.1. React 16.3 deprecates the usage of componentWillMount, componentWillReceiveProps, and componentWillUpdate. These have been replaced with static lifecycle methods: getDerivedStateFromProps and getSnapshotBeforeUpdate, but only getDerivedStateFromProps is available in 16.3.0-alpha.1.

  • 在 iOS 上,WebBrowser.dismissBrowser() Promise 现在解析为 {type:'dismiss} 而不是 {type:'dismissed'} 以匹配 Android

    ¥On iOS, WebBrowser.dismissBrowser() promise now resolves with {type:'dismiss} rather than {type:'dismissed'} to match Android

  • AdMob 方法名称更改requestAdrequestAdAsyncshowAdshowAdAsyncisReadygetIsReadyAsync

    ¥AdMob method name changes. requestAd to requestAdAsync, showAd to showAdAsync, isReady to getIsReadyAsync.

  • 在 iOS 上,联系人 urls 已重命名为 urlAddresses 以匹配 Android。相关提交

    ¥On iOS, Contacts urls was renamed to urlAddresses to match Android. Related commit.

  • 在 iOS 上,如果你没有发送通知的权限,调用 Notifications.getExpoPushToken() 将引发错误。我们建议在获取推送令牌之前致电 Permissions.getAsync(Permissions.NOTIFICATIONS),如果需要并且你之前没有询问过,请致电 Permissions.askAsync(Permissions.NOTIFICATIONS)

    ¥On iOS, calling Notifications.getExpoPushToken() will throw an error if you don't have permission to send notifications. We recommend call Permissions.getAsync(Permissions.NOTIFICATIONS) and, if needed and you haven't asked before, Permissions.askAsync(Permissions.NOTIFICATIONS) before getting push token.

  • React Native 0.53.0 删除了 TextInput autoGrow 属性。提交

    ¥React Native 0.53.0 removed the TextInput autoGrow prop. Commit.

SDK 25

博客文章

¥Blog Post

从 SDK 24 升级

¥Upgrade from SDK 24

  • 在 app.json 中,将 sdkVersion 更改为 "25.0.0"

    ¥In app.json, change sdkVersion to "25.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
  "expo": "^25.0.0",
  "react": "16.2.0"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • 如果你的项目中有任何依赖于 metro-bundler 的脚本,则需要将其更改为 metro (相关提交)。可能的地点是 rn-cli.config.js

    ¥If you have any scripts in your project that depend on metro-bundler, you will need to change those to metro (related commit). A likely place for this is in rn-cli.config.js.

  • 尽管从技术上讲 React Navigation 并不是 SDK 的一部分,但 Expo 用户普遍使用 React Navigation,值得一提的是,在 Android 上 React Navigation 现在可以正确地解决半透明状态栏的问题。这可能需要你删除必须解决该问题的代码(可能是某个地方的 paddingTop 以避免内容在状态栏下方渲染)。阅读 React Navigation 发行说明以获取更多信息。仅适用于 react-navigation@1.0.0-beta.26 及更高版本。

    ¥Although not technically part of the SDK, React Navigation is commonly used by Expo users, and it's worth mentioning that on Android React Navigation now properly accounts for the translucent status bar. This may require you to remove code that you have to workaround that (maybe a paddingTop somewhere to avoid the content from rendering underneath the status bar). Read the React Navigation release notes for more information. Only applies to react-navigation@1.0.0-beta.26 and higher.

SDK 24

博客文章

¥Blog Post

从 SDK 23 升级

¥Upgrade from SDK 23

  • 在 app.json 中,将 sdkVersion 更改为 "24.0.0"

    ¥In app.json, change sdkVersion to "24.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-24.0.0.tar.gz",
  "expo": "^24.0.0",
  "react": "16.0.0"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

以下 API 在至少 2 个版本弃用后已被删除:

¥The following APIs have been removed after being deprecated for a minimum of 2 releases:

  • Expo.LegacyAsyncStorage

  • Expo.Font.style

  • 不再支持将对象传递到 Expo.SQLite.openDatabase() 而不是单独的参数。

    ¥Passing an object into Expo.SQLite.openDatabase() instead of separate arguments is no longer supported.

SDK 23

博客文章

¥Blog Post

从 SDK 22 升级

¥Upgrade from SDK 22

  • 在 app.json 中,将 sdkVersion 更改为 "23.0.0"

    ¥In app.json, change sdkVersion to "23.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-23.0.0.tar.gz",
  "expo": "^23.0.0",
  "react": "16.0.0"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

  • React Native 不再支持 <Image> 内的嵌套组件 - 一些开发者使用它来使用图片作为其他视图后面的背景。要在你的应用中修复此问题,请将 Image 组件替换为 ImageBackground 组件,其中你在其中嵌套视图的任何位置,如下所示:

    ¥React Native no longer supports nesting components inside of <Image> — some developers used this to use an image as a background behind other views. To fix this in your app, replace the Image component anywhere where you are nesting views inside of it with the ImageBackground component, like this:

<View style={styles.container}>
  <ImageBackground
    source={require('./path/to/image.png')}
    style={{
      width: 280,
      alignItems: 'center',
      justifyContent: 'center',
      padding: 30,
    }}>
    <Text style={{ color: '#fff', fontSize: 18 }}>
      The universe... what a concept. You know, the universe is a little bit like the human hand.
      For example, you have groundmen's center right here and then you have undiscovered worlds and
      uh, um and sector 8 and up here is tittleman's crest so you can kinda picture it's a little
      bit like a leaf or uhh, umm, it's not a bowl.
    </Text>
  </ImageBackground>
</View>
  • React Native 现在在 Metro 打包器(React Native 的默认打包器)中将 enableBabelRCLookup(递归)默认为 false。这不太可能给你的应用造成任何问题 — 在我们的例子中,这让我们可以删除一个脚本,以便在安装后从 node_modules 中删除嵌套的 .babelrc 文件。如果你在更新应用时遇到转换错误,请 阅读此提交消息以获取更多信息 并了解如何选择旧行为。

    ¥React Native now defaults enableBabelRCLookup (recursive) to false in Metro bundler (the default bundler for React Native). This is unlikely to cause any problems for your application — in our case, this lets us remove a script to delete nested .babelrc files from node_modules in our postinstall. If you run into transform errors when updating your app, read this commit message for more information and to see how to opt-in to the old behavior.

SDK 22

博客文章

¥Blog Post

从 SDK 21 升级

¥Upgrade from SDK 21

  • 在 app.json 中,将 sdkVersion 更改为 "22.0.0"

    ¥In app.json, change sdkVersion to "22.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-22.0.1.tar.gz",
  "expo": "^22.0.0",
  "react": "16.0.0-beta.5"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

Metro Bundler(默认的 React Native 打包器)现在出现错误(而不是默默地忽略)动态需求。特别是,如果你正在使用 moment.js 的旧版本(或间接依赖于它),这会破坏它。

¥Metro Bundler (the default React Native bundler) now errors (instead of silently ignoring) dynamic requires. In particular this breaks an older version of moment.js if you were using that (or indirectly depending on it).

  • 这是 Metro 正在项目的 GitHub 问题上进行跟踪 的一个已知问题。

    ¥This is a known issue with Metro which is being tracked on the project's GitHub issues.

  • 如果你在应用中使用 moment.js,则 你可能会成功修复此问题

    ¥If you use moment.js in your app, you may have success with this fix.

一些已弃用的 API 已被删除。所有这些 API 在以前的版本中都会打印警告消息:

¥Several deprecated APIs have been removed. All of these APIs printed warning messages in previous releases:

  • Expo.Notifications.getExponentPushToken 现在是 Expo.Notifications.getExpoPushToken

    ¥Expo.Notifications.getExponentPushToken is now Expo.Notifications.getExpoPushToken.

  • Expo.AdMob.AdMobInterstitials.tryShowNewInterstitial 已被删除,取而代之的是 requestAdshowAd

    ¥Expo.AdMob.AdMobInterstitials.tryShowNewInterstitial has been removed in favor of requestAd and showAd.

  • Expo.Segment.initializeAndroidinitializeIOS 已被删除,取而代之的是 Expo.Segment.initialize

    ¥Expo.Segment.initializeAndroid and initializeIOS have been removed in favor of Expo.Segment.initialize.

  • Expo.BlurViewtintEffect 属性已被删除,取而代之的是着色属性。

    ¥The tintEffect prop of Expo.BlurView has been removed in favor of the tint prop.

  • Expo.SecureStore.setValueWithKeyAsyncgetValueWithKeyAsyncdeleteValueWithKeyAsync 现在是 setItemAsyncgetItemAsyncdeleteItemAsyncsetValueWithKeyAsync 的参数顺序从 (value, key) 更改为 (key, value)

    ¥Expo.SecureStore.setValueWithKeyAsync, getValueWithKeyAsync, and deleteValueWithKeyAsync are now setItemAsync, getItemAsync, and deleteItemAsync. The order of arguments to setValueWithKeyAsync changed from (value, key) to (key, value).

  • Expo.VideoExpo.Audiocallback 属性现在是 onPlaybackStatusUpdate。这还不是重大更改,但我们计划在 SDK 24 中删除 LegacyAsyncStorage。如果你或你使用的任何库。使用 View.propTypes.style 你需要将其更改为 ViewPropTypes.style

    ¥The callback prop of Expo.Video and Expo.Audio is now onPlaybackStatusUpdate. This is not a breaking change yet but we plan to remove LegacyAsyncStorage in SDK 24. If you, or any libraries that you use. use View.propTypes.style you will need to change that to ViewPropTypes.style.

如果你尚未按照先前版本中的弃用警告中的警告更新 PropTypes 的导入,则需要立即执行此操作。安装 prop-types 包和 import PropTypes from 'prop-types';而不是 import { PropTypes } from React;!同样,如果你依赖 React.createClass,则需要安装 create-react-class 包和 import createReactClass from 'create-react-class'; 如 React 文档中所述

¥If you have not yet updated your imports of PropTypes as warned in deprecation warnings in previous releases, you will need to do this now. Install the prop-types package and import PropTypes from 'prop-types'; instead of import { PropTypes } from React;! Similarly, if you depend on React.createClass, you will need to install the create-react-class package and import createReactClass from 'create-react-class'; as described in the React documentation.

SDK 21

博客文章

¥Blog Post

从 SDK 20 升级

¥Upgrade from SDK 20

  • 在 app.json 中,将 sdkVersion 更改为 "21.0.0"

    ¥In app.json, change sdkVersion to "21.0.0"

  • 在 package.json 中,更改这些依赖:

    ¥In package.json, change these dependencies:

package.json
{
  "react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
  "expo": "^21.0.0",
  "react": "16.0.0-alpha.12"
}
  • 删除项目的 node_modules 目录并再次运行 npm install

    ¥Delete your project's node_modules directory and run npm install again

注意

¥Notes

相机

¥Camera

  • takePicture 函数现在称为 takePictureAsync,现在返回一个具有多个键的对象,而不仅仅是返回 URI。URI 在返回对象的 uri 键下可用。

    ¥The takePicture function is now called takePictureAsync and now returns an object with many keys, instead of just returning the URI. The URI is available under the uri key of the returned object.

  • 以前这个函数会返回一个像这样的值:"file://path/to/your/file.jpg"

    ¥Previously this function would return a value like: "file://path/to/your/file.jpg"

  • 现在将返回一个对象,例如:{ "uri": "file://path/to/your/file.jpg" }

    ¥And will now return an object like: { "uri": "file://path/to/your/file.jpg" }

安全存储

¥Secure Store

  • setValueWithKeyAsyncsetItemAsync:参数的顺序已颠倒,以匹配典型的键值存储 API。该函数过去期望 (value, key),现在期望 (key, value)

    ¥setValueWithKeyAsyncsetItemAsync: The order of the arguments has been reversed to match typical key-value store APIs. This function used to expect (value, key) and now expects (key, value).

  • getValueWithKeyAsyncgetItemAsync:尝试检索不存在的条目将返回 null 而不是抛出错误。

    ¥getValueWithKeyAsyncgetItemAsync: Trying to retrieve an entry that doesn't exist returns null instead of throwing an error.

  • deleteValueWithKeyAsyncdeleteItemAsync

付款方式

¥Payments

  • 我们之前曾宣布 iOS 上支持 Stripe,作为我们实验性 DangerZone API 的一部分。Payments API 在 iOS 上使用 Stripe SDK。我们了解到,Apple 有时会拒绝包含 Stripe SDK 但不提供任何销售的应用。为了帮助你的应用审核流程更加顺利,我们决定从使用 Expo 独立构建器构建的应用中删除 Stripe SDK 和实验性支付 API。我们仍然很高兴为开发者提供一种让用户在需要时支付商品费用的方法,并且我们将很快宣布更多这样做的方法。

    ¥We had previously announced Stripe support on iOS as part of our experimental DangerZone APIs. The Payments API was using the Stripe SDK on iOS. We learned that Apple sometimes rejects apps that contain the Stripe SDK but doesn't offer anything for sale. To help your App Review process go more smoothly, we have decided to remove the Stripe SDK and experimental Payments API from apps built with the Expo standalone builder. We are still excited to give developers a way to let users pay for goods when they need to and we will announce more ways to do so shortly.

Expo 中文网 - 粤ICP备13048890号