
React Component-UI ์์
API- ์์คํ
ํธ์ถ
import React from 'react';
import { Button, Text, View, StyleSheet } from 'react-native';
function singleNumber(props) {
return (
<view style={styles.circle}>
<Text style={styles.label}>{props.number}</Text>
</view>
);
}
const styles = StyleSheet.create({
circle: {
width: 100,
height: 100,
backgroundColor: "#fff",
justifyContent: 'center',
alignItems: 'center'
},
label: {
fontSize: 20,
fontWeight: 'bold'
}
});
export default singleNumber;
View์ ์ ์ฉํ ์ ์๋ style: ViewStyle(๋ฐ๋ผ์ textstyle์ ์ ์ฉ ๋ถ๊ฐ)
props ๋๊ฒจ ๋ฐ๊ธฐ
const Circle = styled.View` ${(props) => { if (props.number < 11) { return 'background: yellow;'; } else if (props.number < 21) { return 'background:blue;'; } }} `;๋ณด๋ค react์ค๋ฝ๊ฒ ๋ง๋ค ์ ์๊ณ , ์ปดํฌ๋ํธ๊ฐ ํ๋ ์ผ๋ค์ด ์์์ง๊ฒ ๋จ
const Container = styled.ImageBackground`
flex:1;
justify-content: center;
align-items: center;
`;
<Container source={{url: 'https://placeimg.com/1280/1280/nature'}}resizeMode = {'stretch'}>