The following video explains what is going on https://www.loom.com/share/c9144a0877b1460c8c02c301afdc3029
There is a noticeable jump in the text when the text is entered. This is what the code for the text input looks like. i already tried scrollenabled=false. Any ideas would be welcome.
<TextInput
placeholder={'What do you want to talk about?'}
placeholderTextColor={'#9A9A9A'}
onChangeText={onChangeText}
multiline={true}
autoFocus={true}
scrollEnabled={true}
style={[styles.textInputPost, postVideoUri.length > 0 || postImage.length > 0 ? { height: '20%' } : {}]}
/>
3
Answers
ok so i found a solution. it has two components.
use useCallback() for onchangeText function.
provide a width component for the textInput field. That is critical for the solution to work. With both of these things, it will not jump.
},
It behaves like that because you are probably calling the
setState()
function directly on change, which triggers a re-render every time you edit text input content. For text inputs, I recommend to use the React-Hook-Form library and use Controller to make it controlled input; then it should work fine.Probably, because you are using
useState
hook to manage the state, some re-renders happen and that is why that happens. Maybe try something like this: