React/ReactNative

기본 코드 설명

하로이 2024. 7. 9. 15:36
import { Text, SafeAreaView, StyleSheet } from 'react-native';

// You can import supported modules from npm
import { Card } from 'react-native-paper';

// or any files within the Snack
import AssetExample from './components/AssetExample';

export default function App() {
  return (
    <SafeAreaView style={styles.container}>
      <Text style={styles.paragraph}>
        Change code in the editor and watch it change on your phone! Save to get a shareable url.
      </Text>
      <Card>
        <AssetExample />
      </Card>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

 

알아야 할 점

1. div 대신 View를 사용 그러니 import 항상 하기

2. 모든 text는 text component에 들어가야 한다.

3. 웹에서 사용하던 모든 것을 사용할 수 없다.

4. StyleSheet.create는 style object 만드는거임 이걸 빼고 만들 수 있으나 style 자동완성이 안나온다.

'React > ReactNative' 카테고리의 다른 글

React Native 레이아웃  (0) 2024.07.30
리액트네이티브 설치  (0) 2024.07.30
기본 설치 및 이해 (2)  (0) 2024.07.08
기본 설치 및 이해 (1)  (0) 2024.07.05