less than 1 minute read

React Native

TextInput

https://reactnative.dev/docs/textinput

onSubmitEditing

submit를 부르면 발생하는 이벤트

returnKeyType

return 이라는 버튼의 이름을 바꾸고싶을떄 사용

API

ScrollView

속성

  • showsHorizontalScrollIndicator : 스크롤을 보임/안보임 여부
  • pagingEnabled : 스크롤이 페이지당 넘어가게 만들어줌
  • horizontal : 수평 스크롤

expo API

location

위치 정보 api

  const [city, setCity] = useState("Loading...");
  const [location, setLocation] = useState();
  const [ok, setOk] = useState(true);
  const ask = async () => {
    const { granted } = await Location.requestForegroundPermissionsAsync();
    if (!granted) {
      setOk(false);
    }
    const {
      coords: { latitude, longitude },
    } = await Location.getCurrentPositionAsync({ accuracy: 5 });
    const location = await Location.reverseGeocodeAsync(
      { latitude, longitude },
      { useGoogleMaps: false }
    );
    setCity(location[0].city);
  };
  useEffect(() => {
    ask();
  }, []);

TODO

image

위처럼 object객체를 만들어 toDos상태를 관리

hashmap을 사용하는데 id는 Date.now()로 생성해 관리, id만 삭제하면 todo가 삭제되므로 유용하다.

!! 리액트에서는 배열에 추가해주지 않고 새로운 객체를 만들어 합친다. state를 절때 직접 수정하면 안된다.

Object.assign() 사용

Updated: