0

this is the code I wrote in react-native application and I've added the image about the error I am getting when I run the app on android virtual device.

import React from 'react';
import { Text, View } from 'react-native';
const Header = () => {
 const { textStyle, viewStyle } = styles;
 return (
 <View style={viewStyle}>
 <Text style={textStyle} >Albums!</Text>;
 </View>
 );
};
const styles = {
 viewStyle: {
 backgroundColor: '#F8F8F8'
 },
 textStyle: {
 fontSize:20
 }
};
export default Header;

The error is as follows:

Invariant Violation: Text strings must be rendered within a <Text> component.

Cœur
39k25 gold badges206 silver badges281 bronze badges
asked Jul 31, 2018 at 18:13
4
  • 1
    Please post what the error is and what the desired outcome is Commented Jul 31, 2018 at 18:15
  • @JeremyLee Sir i've added the link to image to what the error is Commented Jul 31, 2018 at 18:30
  • I don't see the link.. my edit may have overwritten yours? Commented Jul 31, 2018 at 18:37
  • @JeremyLee Sir I've added the image again :) Commented Jul 31, 2018 at 19:18

2 Answers 2

0

Just remove the semicolon which is after the text closing tag.

return (
 <View style={viewStyle}>
 <Text style={textStyle} >Albums!</Text> "remove this semicolon ->;"
 </View>
);
answered Jul 31, 2018 at 19:27
Sign up to request clarification or add additional context in comments.

Comments

0

if you want that ! you can write code like this

return (
<View style={viewStyle}>
<Text style={textStyle} >{"Albums!"}</Text>
</View>

);

answered Aug 1, 2018 at 7:53

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.