如何将 RecyclerListView 从类组件转移到功能

问题描述

我第一次在遗留代码中遇到 RecyclerListView,所以我需要以函数风格重写它,但是当 React 尝试返回 RecyclerListView 时,程序冻结甚至不进入 renderBetItem 函数,console.log 甚至不出现.这是代码部分

let dataProvider = new DataProvider((r1,r2) => {
        return true;
    });

let layoutProvider = new LayoutProvider(
    () => 0,(type,dim) => {
        dim.width = width;
        dim.height = 110;
    }
);    
componentDidMount() {
        this.setState({isLoading: true});
        this.props.footballEvents && this.initialManipulations(this.props.footballEvents);
        this.setState({isLoading: false});
    }

initialManipulations = (events) => {
        if (events.length) {
            const newEventArr = events.map((event) => eventManipulations(event,'fromFootball'));
            this.setState({liveEvents: this.dataProvider.cloneWithRows(newEventArr),loading: false});
        }
    }
const renderBetItem = (type,data) => {
        console.log('entered renderBetItem')
        return (
            <View><Text>Hello</Text></View>
        )
    }

return (
        <View style={{backgroundColor: whiteLabel.mainBackground,flex: 1}}>
            {isLoading === false ?
                <RecyclerListView
                    roWrenderer={renderBetItem}
                    key={keyForLive}
                    dataProvider={liveEvents}
                    layoutProvider={layoutProvider}
                />
                :
                <ActivityIndicator
                    color={whiteLabel.hoMetabColorActive}
                    size='large'
                    style={{marginTop: '20%'}}
                />
            }
        </View>
    )
Do you have any idea what`s wrong with this code?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)