React native undefined is not a function [duplicate]

给你一囗甜甜゛ 提交于 2019-12-11 16:44:17

问题


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:


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

_renderContent = (section, i, isActive) => {


来源:https://stackoverflow.com/questions/50434988/react-native-undefined-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!