我正在用 React Native 进行新开发。
首先,我npx react-native init hello_world --template react-native-template-typescript创建了基本代码,然后用以下代码替换了 app.tsx:
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
const App = () => {
return (
<View style={styles.helloWorldContainer}>
<Text style={{fontSize: 18}}>Hello, world!</Text>
</View>
);
};
const styles = StyleSheet.create({
helloWorldContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default App;
Run Code Online (Sandbox Code Playgroud)
如果我删除组件文本的样式,错误就会消失。我的问题是如何修复错误,同时保留组件文本中的样式。我看到chrome有很多错误,是否有另一个更好的调试器?
正如Lucas Azambuja Santos所提到的,这是react-native 0.65.*检查新问题时的一个错误https://github.com/facebook/react-native/issues/32197
应使用 0.66 进行修复,以解决降级到 0.64.x 并重建的问题:
cd android && ./gradlew clean cleanBuildCache
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7739 次 |
| 最近记录: |