Javascript 在react native中将多个值作为道具传递给子组件
我有一个这样的父组件Javascript 在react native中将多个值作为道具传递给子组件,javascript,react-native,Javascript,React Native,我有一个这样的父组件 export default class Parent extends Component{ ..... render() { let props = { lat: this.state.lat, long: this.state.long } return( <View style={{flex: 1}}>
export default class Parent extends Component{
.....
render() {
let props = {
lat: this.state.lat,
long: this.state.long
}
return(
<View style={{flex: 1}}>
<Child props = {this.props}/>
</View>
)
}
}
那么在这个案例中我犯了哪些错误呢
(我不会在渲染方法中创建props
变量,这只会让人困惑)谢谢。它起作用了^^^^^^
export default class Child extends Component{
constructor(props) {
super(props)
}
render(){
return (
<View>
<Text>{"Longitude: " + this.props.long}</Text>
<Text>{"Latitude: " + this.props.lat}</Text>
</View>
);
}
}
Longitude: undefined
Latitude: undefined