我正在尝试使用递归在react / react native中显示线程注释。
我想我已经接近了,但是还有些小事。
这是我的评论部分:
beforeEach(function() {
cy.viewport(1680,1050);
});
const pages=[
"https://URL1",
"https://URL2",
"https://URL3",
"https://URL4"
]
describe('screencheck', () => {
it('scree', () => {
cy.login().then(()=>{
pages.forEach((page)=>{
cy.setResolution([1680,1050]);
cy.visit(page);
cy.wait(30000);
cy.get('.itl-exit-info-panel > .ng-scope').then(()=>
{
cy.get('.itl-exit-info-panel > .ng-scope').root().matchImageSnapshot(page);
// })
})
});
});
})
})
运行此命令时,我没有遇到任何重大错误,但是在应显示注释的屏幕上没有任何显示。
我遇到一个小错误:import React, { Component } from 'react';
import { View, FlatList } from 'react-native'
import { Text as NativeText, Header} from 'native-base'
import { withRouter } from 'react-router-native'
import Icon from 'react-native-vector-icons/AntDesign'
class Comment extends Component {
render() { console.log(this.props.location.state.comments)
return(
<View>
<Header rounded
style={{
backgroundColor: '#ffffff',
position: 'relative',
}}
>
<View style={{flexDirection: 'row', flexWrap: 'wrap', right: '43%', top: '50%'}}>
<Icon name='left' size={12} color='#006FFF' style={{top: '4%'}}/>
<NativeText
onPress={() => this.props.history.push('/')}
style ={{color: '#006FFF', fontSize: 12, fontFamily: 'Montserrat-Regular'}}
>
Back
</NativeText>
</View>
</Header>
<CommentList
options={this.props.location.state.comments}
/>
</View>
)
}
}
export default withRouter(Comment)
const CommentList = (options) => {
let listData = options.options.map(option => {
return (option)
})
return (
<View>
<FlatList
data={listData}
renderItem={(item) => {
{console.log('item', item.item.content)}
<View>
<NativeText>{item.item.content}</NativeText>
{
<CommentList
options={item.item.reply}
/>
}
</View>
}}
/>
</View>
)
}