nadinCodeHat
nadinCodeHat

Reputation: 103

Text value doesn't change in React Native app using Class Component

I have this react native app that shows the splash screen first and loads a home screen. The sample home screen shows text as "Demo Display" and I want to change it to "Text Changed!". I'm using a stateful class component. But everytime I try to restart/reinstall/debug the app the text remains same as "Demo Display". How can I fix this?

App.js

import React,{ Component } from 'react'
import { View, Text } from 'react-native'
import SplashScreen from 'react-native-splash-screen'

export default class App extends Component {

  componentDidMount() {
      SplashScreen.hide();
  }

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

This is a screen shot of the app

Upvotes: 3

Views: 114

Answers (1)

Muhammad Affan Aijaz
Muhammad Affan Aijaz

Reputation: 188

Your text is there on the screen but it will not replace the default text. Give some style to your main View and you will see your text there. Try,

<View style={{justifyContent: 'center',alignItems: 'center'}}>
  <Text>Text Changed!</Text>
</View>

Upvotes: 2

Related Questions