as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持

步骤2: 配置文件更新

步骤2: 配置文件更新

2.1 更新babel.config.js

Babel预设已从metro-react-native-babel-preset重命名为@react-native/babel-preset。请在babel.config.js文件中重命名该预设,如下例所示:

// babel.config.js
module.exports = {
  presets: ['module:@react-native/babel-preset'],
};

2.2 更新tsconfig.json

基础TypeScript配置包已从@tsconfig/react-native更改为@react-native/typescript-config。请在tsconfig.json文件中重命名该配置包,如下例所示:

{
  "extends": "@react-native/typescript-config",
  "compilerOptions": {
    "types": ["jest"]
  },
  "include": ["**/*.ts", "**/*.tsx"],
  "exclude": ["**/node_modules", "**/Pods"]
}

2.3 更新.prettierrc.js

prettierrc.js文件中移除bracketSameLinebracketSpacing选项。

// .prettierrc.js
module.exports = {
  arrowParens: 'avoid',
  singleQuote: true,
  trailingComma: 'all',
};

2.4 Metro配置

在从0.72升级到0.83时,除非您有自定义配置,否则无需更改metro.config.js。Metro会随React Native自动更新。

您在升级指南中看到的差异(文档URL变更、类型注释更新)仅为表面调整,不影响功能。Metro配置仅在需要以下新功能时才会更新,例如:

  • unstable_enableSymlinks,用于支持monorepo
  • unstable_allowRequireContext,用于动态调用

如果您的项目没有任何metro.config.js,请勿随意创建。


Last updated: 2026年7月9日