Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RN] onChange vs. onChangeText #24

Open
sbyeol3 opened this issue May 4, 2021 · 1 comment
Open

[RN] onChange vs. onChangeText #24

sbyeol3 opened this issue May 4, 2021 · 1 comment
Labels
study 📝 공부한 자료 공유

Comments

@sbyeol3
Copy link
Member

sbyeol3 commented May 4, 2021

TextInput을 처리하던 중에 onChange 이벤트가 2개가 있어 차이점을 정리해봤습니다 😨

onChange

  • 기존에 사용하는 onChange와 비슷함
  • RN에서는 e.target 이 아니라 e.nativeEvent 객체로 접근
// e.nativeEvent
Object {
  "eventCount": 30,
  "target": 653,
  "text": "Ds",
}

onChangeText

  • onChange의 단순한 버전으로 변경된 value만 바로 파라미터로 전달된다
  • 변경된 값을 사용할 때는 편리하게 사용하기 좋은 이벤트함수
  const onChangeMemo = (e) => {
    console.log(e);
  };

// -> e가 바로 텍스트가 됨
@sbyeol3 sbyeol3 added the study 📝 공부한 자료 공유 label May 4, 2021
@danakim21
Copy link
Member

오오 공유 감사합니다 샛별님!! onChangeText는 단순하게 text 변경값만 가져오는군여

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
study 📝 공부한 자료 공유
Projects
None yet
Development

No branches or pull requests

2 participants