비전공자 개발일기

React & React Native Component 본문

React & React Native

React & React Native Component

HiroDaegu 2022. 1. 11. 21:49
728x90
SMALL

컴포넌트(Component)

  • 재사용이 가능한 조립 블록, 화면에 나타나는 UI 요소
  • 부모로부터 받은 속성(Props)나 자신의 상태(State)에 따라 표현이 달라지고 다양한 기능을 수행
  • (내장 컴포넌트) 

https://reactnative.dev/docs/components-and-apis (View, Text 등)

 

Core Components and APIs · React Native

React Native provides a number of built-in Core Components ready for you to use in your app. You can find them all in the left sidebar (or menu above, if you are on a narrow screen). If you're not sure where to get started, take a look at the following cat

reactnative.dev

https://reactnative.dev/docs/button 

 

Button · React Native

A basic button component that should render nicely on any platform. Supports a minimal level of customization.

reactnative.dev

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';


export default function App() {
  const name = "IRONMAN";
  const age = 100;
  return (
    <View 
      style = {{
        flex: 1,
        backgroundColor: '#fff',
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <Text style = {{fontSize: 30, marginBottom: 10}}>Button Component</Text>
      <Button title = "Button" onPress = {() => {alert("Click!!!!")}}></Button>
    </View>
  );
}

https://reactnative.dev/docs/button#color 

 

Button · React Native

A basic button component that should render nicely on any platform. Supports a minimal level of customization.

reactnative.dev

  • (커스텀 컴포넌트)
import React from "react";
import {Text, TouchableOpacity} from 'react-native';

const MyButton = () => {
  return (
    <TouchableOpacity>
      <Text style = {{fontSize: 24}}>My Button</Text>
    </TouchableOpacity>
  );
};
 
export default MyButton ;
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import MyButton from './src/MyButton'


export default function App() {
  return (
    <View 
      style = {{
        flex: 1,
        backgroundColor: '#fff',
        alignItems: "center",
        justifyContent: "center",
      }}
    >
      <Text style = {{fontSize: 30, marginBottom: 10}}>My Button Component</Text>
      <MyButton></MyButton>
      {/* <Button title = "Button" onPress = {() => {alert("Click!!!!")}}></Button> */}
    </View>
  );
}
 

TouchableOpacity · React Native

If you're looking for a more extensive and future-proof way to handle touch-based input, check out the Pressable API.

reactnative.dev

 

TouchableWithoutFeedback · React Native

If you're looking for a more extensive and future-proof way to handle touch-based input, check out the Pressable API.

reactnative.dev

728x90
LIST

'React & React Native' 카테고리의 다른 글

React Native Pressable  (0) 2022.02.06
React & React Native Props  (0) 2022.01.13
React & React Native JSX  (0) 2022.01.10
React Native - Hello World 출력 및 환경 설정  (0) 2022.01.09
React vs React Native  (0) 2021.12.28