monk
monk

Reputation: 163

Invariant Violation: View config not found for name div

I want to render in react-native project. But simulator shows me the error: Invariant Violation: View config not found for name div What is the matter? Is there a solution for rendering <div> in react-native?

Code sample:

 render() {
    return (
        <div>123</div>
    );
 }

Upvotes: 10

Views: 20418

Answers (2)

Ahsan Ali
Ahsan Ali

Reputation: 5135

<div> is an invalid React Native Component

You should use React Native Basic Components

import { View, Text } from 'react-native';

render() {
    return (
        <View>
            <Text>123</Text>
        </View>
    );
}

View is a container that supports layout with flexbox, style, some touch handling, and access controls. Whereas <Text> can be used in order to display any text.

Upvotes: 26

Dan O
Dan O

Reputation: 6090

the React Native documentation does not list HTML elements as valid view components. There is no view config for <div> because <div> is not a React Native component.

Upvotes: 3

Related Questions