본문 바로가기

React

(29)
React Native / swipe-list-view 1. Install npm install --save react-native-swipe-list-view 2. Usage home.js import React, {useState} from 'react'; import { StyleSheet,View, Text, Button, FlatList, TouchableOpacity} from 'react-native'; import { globalStyles } from '../styles/global' import { RectButton } from 'react-native-gesture-handler' ; import Swipeable from 'react-native-gesture-handler/Swipeable'; import { SwipeListView..
React Native / swipealbe 1. Install npm install @react-navigation/native expo install react-native-gesture-handler react-native-reanimated # expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view 사용방법은 총 2가지 2-1. 사용방법 첫번째 home.js import Swipeable from 'react-native-gesture-handler/Swipeable'; import React, {useState} from ..
React Native / drawer navigation 1. Install npm install @react-navigation/native expo install react-native-gesture-handler react-native-reanimated # expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view npm install @react-navigation/drawer 2. drawer.js 파일 생성 route 폴더 안에 drawer.js / aboutStack.js 파일 생성 drawer.js import React from ..
React Native / Global Style 적용하기, css style을 파일별로 적용하는것이 아니라 한 파일에서 style 태그만 관리하려고 할 때 Global Style을 만들어 사용한다. 1. 먼저 최상위 폴더에 styles 폴더 생성 후, global.js 파일을 만들어준다. global.js import { StyleSheet } from "react-native"; export const globalStyles = StyleSheet.create({ container: { padding:24, flex:1, }, titleText:{ fontFamily:'nunito-bold', fontSize:18, color:'#333', }, paragraph:{ marginVerical:8, lineHeight:20, } }); import { StyleShee..
React Native / navigation option navigation을 사용하면 자동으로 header가 생기는데, options로 header를 조정할 수 있다. homeStack.js import React from 'react'; import { createStackNavigator } from '@react-navigation/stack'; import Home from '../screens/home' import ReviewDetail from '../screens/reviewDetail' import { Button, Text } from 'react-native'; const Stack = createStackNavigator(); export default function HomeStack() { function LogoTitle() { r..
React Native / navigation v5 3(데이터이동) home.js /데이터를 보내는 화면 import React, {useState} from 'react'; import { View, Text, Button, FlatList, TouchableOpacity} from 'react-native'; import { globalStyles } from '../styles/global' export default function Home({navigation}) { const [reviews, setReviews] = useState([ {title:'book a', rating:5, body: 'first book', key:1}, {title:'book b', rating:4, body: 'second book', key:2}, {title:'book c'..
React Native / navigation v5 2(페이지이동) 출발페이지와 도착페이지를 설정 후, 각 페이지에 navigation 변수를 사용해 이동한다. home.js /출발페이지 import React from 'react'; import { View, Text, Button} from 'react-native'; import { globalStyles } from '../styles/global' export default function Home({navigation}) { const pressHandler = () => { // 페이지 이동. navigate = push // 변수는 routes 파일 screens 내 키값을 사용한다 navigation.navigate('ReviewDetail'); // navigation.push('ReviewDetail..
React Native / navigation v5 1 https://reactnavigation.org/docs/getting-started 1. Install npm install @react-navigation/native expo install react-native-gesture-handler react-native-reanimated # expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view react-native-gesture-handler : 뷰를 왼쪽, 오른쪽으로 스와이프 하면 새로운 뷰가 나타나도록 설정 가능 npm inst..