React-Native another VirtualizedList-backed container

后端 未结 15 827
名媛妹妹
名媛妹妹 2020-12-08 13:00

After upgrading to react-native 0.61 i get a lot of warnings like that:

VirtualizedLists should never be nested inside plain ScrollViews with the same orient         


        
15条回答
  •  不知归路
    2020-12-08 13:24

    The best way is to disable that warning because sometimes Flatlist need to be in ScrollView.

    UPDATE RN V0.63 ABOVE

    YellowBox is now changed and replace with LogBox

    FUNCTIONAL

    import React, { useEffect } from 'react';
    import { LogBox } from 'react-native';
    
    useEffect(() => {
        LogBox.ignoreLogs(['VirtualizedLists should never be nested']);
    }, [])
    

    CLASS BASED

    import React from 'react';
    import { LogBox } from 'react-native';
    
    componentDidMount() {
        LogBox.ignoreLogs(['VirtualizedLists should never be nested']);
    }
    

    UPDATE RN V0.63 BELOW

    FUNCTIONAL

    import React, { useEffect } from 'react';
    import { YellowBox } from 'react-native';
    
    useEffect(() => {
        YellowBox.ignoreWarnings(['VirtualizedLists should never be nested']);
    }, [])
    

    CLASS BASED

    import React from 'react';
    import { YellowBox } from 'react-native';
    
    componentDidMount() {
        YellowBox.ignoreWarnings(['VirtualizedLists should never be nested']);
    }
    

提交回复
热议问题