What is Props
const Header = props => {
const { textStyle, viewStyle } = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>{props.headerText}</Text>
</View>
);
};Example
Header Component
// import libraries for making a component
import React from "react";
import { Text, View } from "react-native";
// Make a component
const Header = props => {
const { textStyle, viewStyle } = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>{props.headerText}</Text>
</View>
);
};
const styles = {
// return JSON Object, used to define the CSS Style
textStyle: {
// textStyle is the properties
fontSize: 20
},
viewStyle: {
backgroundColor: "#F8F8F8",
justifyContent: "center",
alignItems: "center",
height: 60,
paddingTop: 15,
// Shadow Related config
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2
},
shadowOpacity: 0.2, // darkness of shadow
//
elevation: 2,
position: "relative"
}
};
// Make the component available to another parts of the app
export default Header;
App
Last updated
Was this helpful?