2022. 1. 12. 13:02ㆍReact Native/Basic

2022.01.11 - [React Native/Basic] - [React Native] React Native Component - 1. Intro
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 2. View, Text
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 3. Style
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 4. TouchEvent
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 5. Button
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 6. ScrollView
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 7. TextInput
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 9. Picker
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 10. Slider
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 11. ActivityIndicator
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 12. Image
2022.01.12 - [React Native/Basic] - [React Native] React Native Component - 13. Modal
6. ScrollView
onMomentumScrollBegin - 스크롤의 움직임이 시작할 때 반응
onMomentumScrollEnd - 스크롤의 움직임이 멈췄을 때 반응
onScroll - 스크롤의 움직임이 발생했을 때 반응. 1px이라도 움직이면 반응한다.
onContentSizeChange - 높이나 너비가 바뀔 때 반응
bounces - 스크롤을 올리거나 내릴 때 통통 튀는 효과.
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */
import React, {Component} from 'react';
import {View, Text, StyleSheet, ScrollView} from 'react-native';
import Header from './src/header';
import Generator from './src/generator';
import NumList from './src/numlist';
class App extends Component {
  state = {
    appName: 'My First App',
    random: [36, 999],
  };
  onAddRandomNum = () => {
    const randomNum = Math.floor(Math.random() * 100) + 1;
    this.setState(prevState => {
      return {
        random: [...prevState.random, randomNum],
      };
    });
  };
  onNumDelete = position => {
    const newArray = this.state.random.filter((num, index) => {
      return position !== index;
    });
    this.setState({
      random: newArray,
    });
  };
  render() {
    return (
      <View style={styles.mainView}>
        <Header name={this.state.appName} />
        <View>
          <Text
            style={styles.mainText}
            onPress={() => alert('text touch event')}>
            Hello World
          </Text>
        </View>
        <Generator add={this.onAddRandomNum} />
        <ScrollView
          style={{width: '100%'}}
          // onMomentumScrollBegin={() => alert('begin')}
          // onMomentumScrollEnd={() => alert('end')}
          // onScroll={() => alert('Scrolling')}
          // onContentSizeChange={(width, height) => alert(height)}
          bounces={true}>
          <NumList num={this.state.random} delete={this.onNumDelete} />
        </ScrollView>
      </View>
    );
  }
}
const styles = StyleSheet.create({
  mainView: {
    backgroundColor: 'white',
    flex: 1,
    paddingTop: 50,
    alignItems: 'center',
    // justifyContent: 'center',
  },
  subView: {
    backgroundColor: 'yellow',
    marginBottom: 10,
  },
  anotherSubView: {
    flex: 2,
    backgroundColor: 'yellow',
    marginBottom: 10,
    width: '100%',
    alignItems: 'center',
    justifyContent: 'center',
  },
  mainText: {
    fontSize: 20,
    fontWeight: 'normal',
    color: 'red',
    padding: 20,
  },
});
export default App;
참고 자료
iOS/Android 앱 개발을 위한 실전 React Native - Basic - 인프런 | 강의
Mobile App Front-End 개발을 위한 React Native의 기초 지식 습득을 목표로 하고 있습니다. 진입장벽이 낮은 언어/API의 활용을 통해 비전문가도 쉽게 Native Mobile App을 개발할 수 있도록 제작된 강의입니다
www.inflearn.com
'React Native > Basic' 카테고리의 다른 글
| [React Native] React Native Component - 8. Button, ScrollView, TextInput 심화 (0) | 2022.01.12 | 
|---|---|
| [React Native] React Native Component - 7. TextInput (0) | 2022.01.12 | 
| [React Native] React Native Component - 5. Button (0) | 2022.01.12 | 
| [React Native] React Native Component - 4. TouchEvent (0) | 2022.01.12 | 
| [React Native] React Native Component - 3. Style (0) | 2022.01.12 |