我有以下代码,Test start
和Test end
都显示。此外,调试器通过areas
和index
正确循环。出于某种原因,它不会在{Object.keys(this.state.firstOccurrence.checklist).forEach
语句中呈现任何内容。我错过了什么?
import React, { Component } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { Container, Header, Title, Content, Footer, FooterTab, Button, Left, Right, Body, Icon, Toast } from 'native-base';
export default class Job extends Component {
[setting state]
render() {
return (
<Container>
{this.state.firstOccurrence != undefined &&
<Content padder>
<View style={styles.container}>
<View>
<Text>Test start</Text>
</View>
{Object.keys(this.state.firstOccurrence.checklist).forEach((area, index) => {
debugger
return (
<View key={index}>
<Text>Test {area}</Text>
</View>
);
})
}
<View>
<Text>Test end</Text>
</View>
</View>
</Content>
}
</Container>
)
}
}
const styles = StyleSheet.create({
container: {
paddingTop: 65,
flexDirection: 'column',
alignItems: 'flex-start'
}
});
答案 0 :(得分:3)
abc
-------------------
def
-------------------
ghi
-------------------
j
返回undefined。你想要.forEach
。