简体   繁体   中英

Exporting Text is showing a Render Error in React Native

I have made a components library for ReactNative using react-native-builder-bob for packaging. With some components like Button, Image, etc is working great, but when I try to import a Text component is failing and showing this error:

View config getter callback for component 'RCTTEXT' must be a function (receive undefined)

If in the project where I import this component do some change, the view is refreshed and the error dissapears, but every time I run the project for first time this error is shown.

Here is the imported component:

import {Text} from 'react-native';

export const MyText = ({...props}) => <Text {...props} />;

And after, this is the way I import this component in another app:

import { MyText } from 'my-library'

export const Example = () => {
   return <MyText>Hello</MyText>
}

I was searching for the error of 'View config getter....' and the only I found is, provocated by importing error, but only happens with this component.

What thing could be provocating this error?

Thanks in advance

Try using your custom text component like this.

import {Text} from 'react-native';

export const MyText = ({children, ...props}) => <Text {...props}>{children}</Text>;

Hope it will solve your problem.

well....finally I found the error. Everything is all great from my library of components, but, apparently, in my component library I have the react-native version 0.68.0 and, in the app where I was importing this components I had a lower version (0.67.3). If I use the same version, it is working!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM