小编sho*_*yme的帖子

道具数据未呈现

我正在尝试在 FlatList 中显示一些数据。数据来自一个 json 文件,并使用 redux 映射到组件 props。我可以从我的组件内部对 props 数据进行 console.log,但我无法在屏幕上呈现它。(this.props.library.title)。相反,我有一个空列表。

我正在学习 udemy 课程,我很确定我完全按照步骤操作

这是我的子组件:

class ListItem extends Component{
    render(){
        //const _this = this;
        const {title,id}=this.props.library ;
        console.log(this.props);
        return(
            <TouchableWithoutFeedback onPerss={()=> this.props.selectLibrary(id)}>
            <View>
        <CardSection>
        <Text style={styles.textStyle}>
            {title}
        </Text>
        </CardSection>
            </View>
            </TouchableWithoutFeedback>
        );
    }
}
const styles ={
    textStyle:{
        fontSize:18,
        padding:5
    }
}
export default connect(null,actions)(ListItem);
Run Code Online (Sandbox Code Playgroud)

这是控制台日志:

https://imgur.com/pd2qbkt

react-native react-redux

3
推荐指数
1
解决办法
70
查看次数

标签 统计

react-native ×1

react-redux ×1