[react native] textinput 입력 시 글자 유실 textinput lose focus react native
반응형
export default () => {
const [content, setContent] = React.useState('');
const InsertData = () => {
return (
<>
<View>
<TextInput
placeholder="텍스트를 입력하세요"
value={content}
onChangeText={(text) => setContent(text)}
</>
</View>
</>
)
}
return (
<>
<View>
<InsertData/>
</View>
</>
)
}
동영상 서비스가 종료되어 해당 콘텐츠를 재생할 수 없습니다.
이렇게 InsertData 라는 component 를 만들고
그 안에서 TextInput 에 텍스트를 입력할 때 마다
계속 쳐지는게 아니라 한글자 치면 focus 가 사라지고;;
또 클릭해서 한글자 치고...
계속 저 InsertData() 가 rendering 되는 것이였다 (한글자 칠때마다)
해결방법은 InsertData 를 따로 컴포넌트로 만들어서 import 해서 사용하자
InsertData.js
export default () => {
const [content, setContent] = React.useState('');
return (
<>
<View>
<TextInput
placeholder="텍스트를 입력하세요"
value={content}
onChangeText={(text) => setContent(text)}
</>
</View>
</>
)
}
export default () => {
import InsertData from './InsertData'
return (
<>
<View>
<InsertData/>
</View>
</>
)
}반응형
글이 도움이 되셨다면 공감과 광고 클릭 한번 부탁드립니다! 💕
감사합니다 ✨
댓글
이 글 공유하기
다른 글
-
[ios] apple 개발자 계정으로 dropbox 로 ad-hoc(OTA) 배포하기 (1)
[ios] apple 개발자 계정으로 dropbox 로 ad-hoc(OTA) 배포하기 (1)
2021.01.26 -
[ios] iPhone UDID windows / mac 에서 간단 확인 방법!
[ios] iPhone UDID windows / mac 에서 간단 확인 방법!
2021.01.26 -
[react native] Invariant Violation: View config getter callback for component `firstView` must be a function (received `undefined`). Make sure to start component names with a capital letter.
[react native] Invariant Violation: View config getter callback for component `firstView` must be a function (received `undefined`). Make sure to start component names with a capital letter.
2021.01.08 -
[react native] react-native-calendars 캘린더에 마킹하기
[react native] react-native-calendars 캘린더에 마킹하기
2021.01.07