비전공자 개발일기

React Native Pressable 본문

React & React Native

React Native Pressable

HiroDaegu 2022. 2. 6. 17:39
728x90
SMALL

정의된 자식에 대한 다양한  Press 상호 작용 단계를 감지할 수 있는 핵심 구성 요소

 

import React from 'react';
import {View, Text, Pressable} from 'react-native';

const Button = props => {
  return (
    <Pressable
      style={{padding: 10, backgroundColor: '#2598eb'}}
      onPressIn={() => {
        console.log('Press In');
      }}
      onPressOut={() => {
        console.log('Press Out');
      }}
      onPress={() => {
        console.log('Press');
      }}
      onLongPress={() => {
        console.log('Long Press');
      }}
      delayLongPress={3000}
      pressRetentionOffset={{button: 50, left: 50, right: 50, top: 50}}
      hitSlop={50}>
      <Text style={{padding: 10, fontSize: 30}}>{props.title}</Text>
    </Pressable>
  );
};

const App = () => {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        backgroundColor: '#fff',
        alignItems: 'center',
      }}>
      <Button title="Pressable"></Button>
    </View>
  );
};
export default App;

728x90
LIST

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

React Native Webview2  (0) 2022.02.14
React Native Webview  (0) 2022.02.13
React & React Native Props  (0) 2022.01.13
React & React Native Component  (0) 2022.01.11
React & React Native JSX  (0) 2022.01.10