React native undefined is not a function [duplicat

2019-08-23 16:01发布

This question already has an answer here:

I am new to react native. I am trying to push to another page. But i am getting error saying

Undefined is not a function(evaluating '_this2._goToProductListing('app.productListing'{title:item.title})')

My code is this

 _renderContent(section, i, isActive) {
        return (
            <View>
                <List>
                    {section.content.map((item, i) => {
                        return(
                            <ListItem containerStyle={styles.categoryLists}
                                      onPress={() => this._goToProductListing('app.productListing',{title:item.title})}
                                      key={i} title={item.title}
                            />
                        );
                    })}
                </List>
            </View>
        );
    }


    //Send to product list page
    _goToProductListing = (screen,data) => {
        this.props.navigator.push({
            screen: screen,
            title: data.title,
            passProps: {
                data: data
            }
        });
    };
render() {
        return (


            <View style={stylesheet.accrodianWraper}>

                <ScrollView>
                    <Accordion
                        activeSection={this.state.activeSection}
                        sections={CONTENT}
                        touchableComponent={TouchableOpacity}
                        renderHeader={this._renderHeader}
                        renderContent={this._renderContent}
                        duration={0}
                        onChange={this._setSection.bind(this)}
                    />
                </ScrollView>
            </View>
        )
    }

Can anyone please tell me where i am doing wrong?? And how can i fix it?

For navigation i am using wix react native navigation, And the page app.productListing is also registered in the index.js. And i am using react-native-collapsible for accordion, B

1条回答
走好不送
2楼-- · 2019-08-23 16:31

Try making the _renderContent a property with an arrow function too:

_renderContent = (section, i, isActive) => {
查看更多
登录 后发表回答