๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Kawai ToDo ๋”ฐ๋ผ ๋งŒ๋“ค๊ธฐ

Dimensions API#

Dimensions ยท React Native

import {Dimensions} from 'react-native';
const windowWidth = Dimensions.get('window').width;const windowHeight = Dimensions.get('window').height;
or;
const {height, width} = Dimensions.get('window');

์‚ฌ์šฉํ•˜๋Š” ํ•ธ๋“œํฐ(์œˆ๋„์šฐ ๊ฐ์ฒด)์˜ ๊ฐ€๋กœ ๋„ˆ๋น„, ์„ธ๋กœ ๋„ˆ๋น„๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค.

Platform Specific Code#

Platform Specific Code ยท React Native

import {Platform, StyleSheet} from 'react-native';
const styles = StyleSheet.create({    height: Platform.OS === 'ios' ? 200 : 100,});
import {Platform, StyleSheet} from 'react-native';
const styles = StyleSheet.create({    container: {        flex: 1,        ...Platform.select({            ios: {                backgroundColor: 'red',            },            android: {                backgroundColor: 'blue',            },        }),    },});

Shadow Props#

Shadow Props ยท React Native

...Platform.select({  ios: {    shadowColor: "rgb(50, 50, 50)",    shadowOpacity: 0.5,    shadowRadius: 5,    shadowOffset: {      height: -1,      width: 0    }  },  android: {    elevation: 3  }})

shadow ๋Š” iOS์™€ Android์—์„œ ์†์„ฑ์ด ๋‹ค๋ฅด๋‹ค. Android๋Š” elevation ์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค .

ScrollView#

์Šคํฌ๋กค๋ทฐ ์ปดํฌ๋„ŒํŠธ ์•ˆ์— ToDo ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋„ฃ๋Š”๋‹ค.

<ScrollView>    <ToDo /></ScrollView>

TextInput#

  • placeholderTextColor : ํ”Œ๋ ˆ์ด์Šคํ™€๋” ํ…์ŠคํŠธ ์ƒ‰๊น”

  • onChangeText : ํ…์ŠคํŠธ๊ฐ€ ๋ฐ”๋€Œ๋ฉด ์‹คํ–‰๋  ์ฝœ๋ฐฑํ•จ์ˆ˜

  • autoCorrect : ํ…์ŠคํŠธ ์ž๋™์ˆ˜์ • (false๋กœ ํ•˜๋Š”๊ฒŒ ํŽธํ•  ๋“ฏ)

  • returnKeyType : ํ‚ค๋ณด๋“œ ๋ ˆ์ด์•„์›ƒ์—์„œ ํ‘œ์‹œ๋  ๋ฌธ๊ตฌ

<TextInput returnKeyType={'done'} />

2020-03-22-kawai-todo-๋”ฐ๋ผ-๋งŒ๋“ค๊ธฐ-image-0

setState#

React.Component - React

ํ•จ์ˆ˜ํ˜• setState๊ฐ€ ๋ฆฌ์•กํŠธ(React)์˜ ๋ฏธ๋ž˜์ด๋‹ค(Functional setState is the future of React)

๋ˆ„๊ตฌ๋“ ์ง€ ํ•˜๋Š” ๋ฆฌ์•กํŠธ 4ํŽธ: props ์™€ state

_toggleComplete = () => {    this.setState((prevState) => {        return {            isCompleted: !prevState.isCompleted,        };    });};

๐Ÿ“Œ setState ์— updater ํ•จ์ˆ˜๋ฅผ ๋„ฃ๋Š” ๊ฒƒ์ด ์ดํ•ด๋˜์ง€ ์•Š์Œ.

  • setState ํ•จ์ˆ˜์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ํ•จ์ˆ˜๋ฅผ ๋„ฃ๋Š” ๊ฒƒ์ด ์–ด๋–ค ์˜๋ฏธ์ธ๊ฐ€?

  • setState ํ•จ์ˆ˜๋กœ ์ „๋‹ฌ๋˜๋Š” ํ•จ์ˆ˜์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ์–ด๋””์„œ ๋ฐ›์•„์˜ค๋Š” ๊ฒƒ์ธ๊ฐ€?