Jake Chasan
Jake Chasan

Reputation: 6550

Importing React-Native-Elements as an Object is Undefined

I am having an issue using elements imported from the react-native-elements library.

I have installed the latest version of both XDE (and project is a new CRNA) and React-Native-Elements.

I then import the library with the following which generates no errors:

import RNElements from 'react-native-elements';

I attempt to use the element as follows:

<RNElements.Text h1>Heading 1</RNElements.Text>

Which generates the following error:

TypeError: undefined is not an object (evaluating '_reactNativeElements2.default.Text')

The interesting part is that I import both React Native and React Native Elements the same way, and I use their objects in the same way, but only React Native Elements throws an error.

Has anyone seen this error before?

Update: this issue is not with any specific element, it is with the process of importing the library as an object.

Upvotes: 0

Views: 646

Answers (2)

tuan.tran
tuan.tran

Reputation: 1881

You can import all of those element by

import * as RNElements from 'react-native-elements';

then use it: <RNElements.Text h1>Heading 1</RNElements.Text>

Upvotes: 1

oma
oma

Reputation: 1894

Text is not in the react-native-elements components list. Check here the included components: https://github.com/react-native-training/react-native-elements

Upvotes: 0

Related Questions