Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 948
nadinCodeHat Avatar asked Jun 11 '26 19:06

nadinCodeHat


1 Answers

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>
like image 195
Muhammad Affan Aijaz Avatar answered Jun 14 '26 08:06

Muhammad Affan Aijaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!