React Native 0.64 发布,iOS 上 Hermes 支持
React Native 0.64 已经发布了,此版本主要亮点包括:
- 在 iOS 上加入 Hermes
- 默认情况下启用 Inline Requires
- React 17
Hermes opt-in on iOS
在此版本中,用户可以使用 Hermes 在 iOS 上进行构建。要在 iOS 上启用 Hermes,可在你的 Podfile 中设置 hermes_enabled 为 true,然后运行 pod 安装。
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
所有必要的更改将自动完成。值得注意的是,iOS 上对 Hermes 的支持仍处于早期阶段。
默认情况下启用 Inline Requires
Inline Requires 是一个 Metro 配置选项,其已作为一种可选配置选项存在多年。现在,新的应用程序将默认启用 Inline Requires 选项,以帮助人们无需额外配置即可快速使用 React Native 应用程序。
Inline Requires 是一种 Babel 变换,它可以将模块导入并转换为 inline。例如,Inline Requires 将这个模块导入调用从文件的 top 转换到使用它的地方。
Before:
import { MyFunction } from 'my-module';
const MyComponent = (props) => {
const result = myFunction();
return (<Text>{result}</Text>);
};
After:
const MyComponent = (props) => {
const result = require('my-module').MyFunction;
return (<Text>{result}</Text>);
};
更多相关信息可查看文档。
React 17
React 17 不包含面向开发者的新功能,也没有重大的突破性变化。对于 React Native 应用来说,主要的变化是一个新的 JSX 转换,使得文件不再需要导入 React 就能够使用 JSX。
有关 React 17 的更多信息,可参见 React 博客。
完整更新内容可以查看: