- Create Components folder under src folder
- Add stateEXP.js file and add below Code
import React from "react";
import { Text, View } from "react-native";
class stateEXP extends React.Component {
state = {
myState: "Adi"
};
render() {
return (
<View>
<Text>State example</Text>
<Text> {this.state.myState}</Text>
</View>
);
}
}
export default stateEXP;
- Open App.js file and update code as below
import React from 'react';
import { View,StyleSheet } from 'react-native';
import stateEXP from './src/components/stateEXP'
const App=()=> {
return (
<View style={styles.container}>
<stateEXP/>
</View>
);
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop:80
},
});
No comments:
Post a Comment