I know exactly what you need.
Basically you do not want to add the text within the line codes of the messy pages and logics. You rather have a "database" or a page where you can find everything organized for you. Where you can easily change the text and save this page and it will find its way within the app and change it self.
You have to use an OBJECT or an ARRAY and call from it.
First of all, create an page and call it (for example: DynamicText.js)
Add your data in similar fashion:-
If you want to use an ARRAY .. do the following :-
export const someInfo = [
{
"Text": "Mobile Phones" // This is what we want to PUSH !
},
{
"Text": "All copy rights reserved"
},
{
"Text": "Mobile Phones"
},
];
Then, go to your screens, where you want to have this dynamic pages added.
Then import the code on top
import someInfo from '../data/DynamicText';
and finally this is how you render a text or calling a text from an array without too much hastle.
{someInfo[0].text}
So just basically through it inside the exactly like that.
Thats it ! the number [0] goes in order.
To use it in your code:-
export default class User extends Component{
render(){
return(
<View style={styles.mainBoxes}>
<Text style={styles.mainBoxesText}>{someInfo[0].text}
</Text>
</View>
);
}
}
The better method is by using an OBJECT, since it is all about "TEXT" !
To make an object you basically do the following:-
export const someInfo = {
heading: " This is the heading Text",
subtitle: "This is the subtitle Text",
comment: "the pizza is delicious"
},
and to use in code is quite simple.
{someInfo.heading}
Heppy Coding !