2 回答
TA贡献1864条经验 获得超6个赞
你的意思是这样的?
import React from 'react';
import {Text, View, StyleSheet, Button, ScrollView} from 'react-native';
export default class MainFilter extends React.Component {
constructor(props){
super(props);
this.state ={ isLoading: true};
this.filterURL = this.props.filterURL;
}
componentDidMount(){
init(this.filterURL).then(resp => {
this.setState({
filter: resp['fullFilter'],
filterKeys: resp['filterKeys'],
isLoading: false
});
})
}
filterList(isLoading) {
const {filterKeys, fullFilter} = this.state;
return isLoading ? filterKeys.map((item) => (
<View key={item} style={styles.container}>
<View style={{flex: 1, flexDirection: 'row'}}>
<View style={{borderWidth: 2.5, borderColor: '#00FF00',width: '50%'}}>
<Text style={{fontSize: 19, fontWeight: 'bold'}}>{item}</Text>
<Text style={{fontSize: 16}}>{fullFilter[item]}</Text>
</View>
<View>
<Text>KEKEKEK</Text>
</View>
</View>
<Button key={item} title={"ADD TO FOCUS"} onPress={function() {console.log(item)}}/>
</View>
) : (
<View>
<Text>Component is LOADING</Text>
</View>
));
}
render(){
let filterIndex = {};
for(let i = 0; i < filterList.length; i++)
{
filterIndex[filterList[i].key] = filterList[i]
}
console.log(filterIndex);
return(
<ScrollView style={{flex: 1, paddingTop:20}}>
{this.filterList(this.state.isLoading)}
</ScrollView>
);
}
}
对糟糕的格式感到抱歉。
添加回答
举报