不变的 viloation:对象作为 React 子项无效(已找到:具有键 {fontweight,fontsize} 的对象)
Invariant viloation: Objects are not valid as a React child(found: object with keys {fontweight, fontsize})
代码未读取字体粗细和字体大小的值,但与容器完美配合。我该如何解决?
import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
export default class Splash extends Component {
render() {
return (
<View style={styles.container}>
<Text> style={styles.title} </Text>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
title: {
fontWeight: 'bold',
fontSize: 18
}
})
在这行代码中
<Text> style={styles.title} </Text>
请改为:
<Text style={styles.title}>my data </Text>
代码未读取字体粗细和字体大小的值,但与容器完美配合。我该如何解决?
import React, { Component } from 'react'
import { StyleSheet, Text, View } from 'react-native'
export default class Splash extends Component {
render() {
return (
<View style={styles.container}>
<Text> style={styles.title} </Text>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
title: {
fontWeight: 'bold',
fontSize: 18
}
})
在这行代码中
<Text> style={styles.title} </Text>
请改为:
<Text style={styles.title}>my data </Text>