首页 > 解决方案 > 试图将“[RCTVirtualText 507]”添加到“[RCTView 509]”)?

问题描述

我一直在为 Web 开发我的应用程序,它一直在正常工作。但是,当我在 Expo / Android 中运行相同的应用程序时,我收到了这个错误。从描述中很难知道它是关于什么的。

这是完整的错误消息:

Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a '[RCTVirtualText 507]' to a '[RCTView 509]') 

你知道它可能是什么吗?

这似乎是触发它的 js 文件:

...
export class SubjectListAssignScreen extends React.Component {

    state = {

        subjectList: [],

        subListLoading: true,

    };

    constructor(props) {
        super(props);
    };

    scrollDimensions = [{
        width: Math.round(Dimensions.get('window').width - 20),
        maxHeight: Math.round(Dimensions.get('window').height - 200)
    }];
...
    _getSubjects = async(text) => {

        try {

            await this.setState({ subListLoading: true });

            let lQueryRes = await API.graphql(graphqlOperation(cqueries.listSubjectsCustom, {}));

            await console.log('==> Subjects Query');
            await console.log(lQueryRes);

            await this.setState({ subjectList: lQueryRes.data.listSubjects.items });

            await this.setState({ subListLoading: false });


        }
        catch (e) {

            console.log("==> DB Error");
            console.log(e);

            await this.setState({ subListLoading: false });

        };
    };

...
 _subjectItems = (value) => {

        console.log(value.desc);

        let lnum = (typeof value["num"] !== 'undefined') ? value["num"].toString() : null;
        let desc = value["desc"].toString();
        let lastName = (typeof value["users"][0] !== 'undefined') ? value["users"][0]["lastname"].toString() : null;
        let ltype = value["type"].toString();

        return (
            <DataTable.Row onPress={() => {
                this.props.navigation.navigate("UserListScreen", {pnum: lnum, ptype: ltype});
            }}>
                <DataTable.Cell>
                    {this._getTypeIcon(ltype)}
                </DataTable.Cell>
                <DataTable.Cell>
                    <Text>{desc}</Text>
                </DataTable.Cell>
                <DataTable.Cell>
                    <Text>{ lastName }</Text>
                </DataTable.Cell>
            </DataTable.Row>
        );
    };

    async componentDidMount() {
        try {
            await this._getSubjects();
        }
        catch (e) {
            console.log("==> componentDidMount error");
            console.log(e);
        };
    };

    isCloseToBottom = ({ layoutMeasurement, contentOffset, contentSize }) => {
        const paddingToBottom = 20;
        return layoutMeasurement.height + contentOffset.y >=
            contentSize.height - paddingToBottom;
    };


    fetchMore = () => {

    };


    render() {

        let sDimensions = this.scrollDimensions;

        return (

            <View style={{flex:20, margin:4, flexDirection:"column", justifyContent:"flex-start"}}>
    <Title style={{flex:1}}>Lista de Demandas</Title>
    <SafeAreaView style={[{flex:19, }, sDimensions]}>
        <ScrollView     
            contentContainerStyle={{}}
            onScroll={({nativeEvent}) => {
            if (this.isCloseToBottom(nativeEvent)) {
                this.fetchMore();
            }}}
            >
            <DataTable>
                <DataTable.Header>
                    <DataTable.Title>Type</DataTable.Title>
                    <DataTable.Title>Subj</DataTable.Title>
                    <DataTable.Title>Resp.</DataTable.Title>
                </DataTable.Header>            

                { !this.state.subListLoading ?
                    <FlatList 
                        data={this.state.subjectList}
                        renderItem={({item})=>this._subjectItems(item)}
                        keyExtractor={item => item.desc}
                    />    
                    :
                    <ActivityIndicator />
                }

            </DataTable>        
        </ScrollView>

    </SafeAreaView>
</View>
        )
    }
}

使用 Expo 37、React Native 论文和 AWS Amplify。

标签: react-nativeexpoaws-amplifyreact-native-paper

解决方案


由于我很难找到哪些组件不兼容,我只是放弃了完整的开发环境,创建了一个干净的环境并再次拉取最新的提交,逐个版本检查所有组件并确保所有组件都在-g 版本。之后错误就停止了。


推荐阅读