shodayme
shodayme

Reputation: 33

props data not being rendered

I'm trying to display some data in a FlatList. the data comes from a json file and is mapped to the component props using redux. I can console.log the props data from inside my component but i cant get to render it on screen. (this.props.library.title). Instead I have an empty list.

I'm following a udemy course and i'm pretty sure i followed the steps exactly

here is my child component :

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);

here is the console log :

https://i.sstatic.net/ms6Ew.jpg

Upvotes: 3

Views: 88

Answers (1)

Roozbeh Mohammadzadeh
Roozbeh Mohammadzadeh

Reputation: 689

you should put an item after this.props.library

like this

const { title, id } = this.props.library.item

Upvotes: 3

Related Questions