React Native JSX错误:元素必须包装在一个封闭标签中

时间:2018-09-29 22:08:59

标签: react-native jsx

我不知道为什么我的模拟器出现以下错误:

Adjacent JSX elements must be wrapped in an enclosing tag

代码:

render() {
    return (
    <View>
    <TextInput
        underlineColorAndroid={'transparent'}
        style={styles.searchInput}
        placeholder='Enter Part Name(s)'
    />

    <TextInput
        underlineColorAndroid={'transparent'}
        style={styles.searchInput}
        placeholder='Enter Basic Number(s)'
    />

    <Button
        onPress={this._onBackPressed}
        title='Go'
    </Button>

    </View>
    );
}

1 个答案:

答案 0 :(得分:0)

缺少View标签的开头(节点的开头)。而且该按钮缺少“>”

private void parsSlides() {


        listSLides.clear();

        DatabaseReference dbSLidesRef = FirebaseDatabase.getInstance().getReference("PlusTeam");
        dbSLidesRef.child("Slides").addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

                if (dataSnapshot.exists()) {

                    banner.setVisibility(View.VISIBLE);

                    for (DataSnapshot dt : dataSnapshot.getChildren()) {

                        SliderModels models = dt.getValue(SliderModels.class);
                        listSLides.add(models);
                  sliderBaseAdapter.refreshData(listSLides);
                        Log.d(TAG, "Models: " + models);
                    }
                    Collections.reverse(listSLides);
                } else {
                    banner.setVisibility(View.GONE);
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });


        sliderBaseAdapter = new SliderBaseAdapter(listSLides, getActivity());
        ultra_viewpager.setAdapter(sliderBaseAdapter);
    }

您可以在JSX参考页上找到更多信息:https://reactjs.org/docs/jsx-in-depth.html