Billy Ronaldo Chandra
Billy Ronaldo Chandra

Reputation: 182

passing data into a modal

I'm trying to pass some data from container to modal, and i've done this. it got error undefined is not an object evaluating (evaluating _this.props.status) is there anything i did worng? what should i call in props

these are my codes

container.js

buildPanel(index, item) {
        let panel = [];
        let keys = DBkeys['Requests'].MyRequest;
        
            let status = item[keys['status']];
        panel.push(<View style={{ position: 'absolute', right: 0, bottom: 0, padding: normalize(5), alignItems: 'center' }} key={'status'}>
          <TouchableOpacity onPress={this.handleShowModal()}>
            <Icon name={img.itemStatus[status].name} type={img.itemStatus[status].type} color={img.itemStatus[status].color} size={normalize(38)} />
          </TouchableOpacity>
        </View>);

        return panel;
        }

 <View style={[styles.panelContainer, status === 'success' ? {} : { backgroundColor: color.white }]}>
              <FlatList
                showsVerticalScrollIndicator={false}
                progressViewOffset={-10}
                refreshing={this.state.refreshing}
                onRefresh={this.onRefresh.bind(this)}
                onMomentumScrollEnd={(event) => event.nativeEvent.contentOffset.y === 0 ? this.onRefresh() : null}
                data={content}
                renderItem={({ item }) => item}
                keyExtractor={(item, key) => key.toString()}
                 />
            </View>
            <IconModal visible={this.state.modalVisible} close={this.handleDismissModal} status='test' desc='test' />
        

IconModal.js

const IconModal = (props) => {

    return(
        <Modal 
            isVisible={props.visible}
            onBackdropPress={props.close}
        >
            <View style={styles.dialogBox}> 
                <View style={styles.icon}>
                    <Icon></Icon>
                </View>

                <View style={styles.text}>
                    <Text style={styles.status}>{this.props.status}</Text>
                    <Text>{this.props.desc}</Text>
                </View>
                    <TouchableOpacity onPress={props.close}>
                        <View>
                            <Text style={styles.buttonText}>GOT IT</Text>
                        </View>
                    </TouchableOpacity>
            </View>
            
        </Modal>
    )
}

IconModal.propTypes ={
    visible: PropTypes.bool.isRequired,
    close: PropTypes.func,
}

Upvotes: 1

Views: 87

Answers (2)

Andrei Olar
Andrei Olar

Reputation: 2358

Remove the this keyword. It should be just props.status and props.desc

Upvotes: 1

Nabeel K
Nabeel K

Reputation: 6128

Use double quotes while passing string to the component. like status="test" desc="test" instead of status='test' desc='test' . and instead of this.props.status use props.status. same with this.props.desc

Upvotes: 1

Related Questions