-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
KeyboardAwareScrollView not work in TextInput nested in FlatList component #401
Comments
@elenydev <ScrollView> // <- KeyboardAwareScrollView
<ScrollView> // <- FlatList And <FlatList
renderScrollComponent={KeyboardAwareScrollView}
/> Can you try this and see if it fixes your problem? |
@kirillzyusko thanks for fast reply! Actually, passing the This way it renders the list, but unfortunately it's not solving the issue :( |
@elenydev can you post the code sample here, so that I can run it in my example app and see what exactly is not working? 👀 |
https://snack.expo.dev/@eleny/keyboardavoidingview - You can take straight from here - also You can try to play with renderScrollComponent |
@elenydev here is a slightly modified version of your code: import React from "react";
import { FlatList, TextInput, View } from "react-native";
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
const foo = [...Array(100).keys()];
const KeyboardAvoidingComponent = () => {
return (
<View style={{ flex: 1, background: "black" }}>
<FlatList
data={foo}
renderItem={() => (
<View style={{ width: "100%", height: 50 }}>
<TextInput
placeholder="Some input"
style={{
color: "blue",
margin: 20,
borderColor: "red",
height: 30,
borderWidth: 1,
}}
/>
</View>
)}
renderScrollComponent={(props) => (
<KeyboardAwareScrollView bottomOffset={10} {...props} />
)}
/>
</View>
);
};
export default KeyboardAvoidingComponent;
Works like a charm: flat-list-demo.mp4Let me know if I can close this issue 👀 |
@kirillzyusko Yeah, this way it works, but take a closer look on my example :) you're missing |
@elenydev Ah, you did it with purpose 😅 I thought it was just demonstration of when it works and when not 😅 I think having two nested scroll-views is incorrect layout, because most likely it will break a virtualization of a FlatList (you should receive a warning) -> FlatList will not be able to detect its own size (it'll actually find it, but since it'll be nested in a ScrollView - it will have infinite In your case If you want to have a blue input on top and all other red inputs in FlatList then you can utilize Does it make sense what I'm saying? |
Works like charm :) Great advice, really appreciate that! I'm learning native version of React, all of those tips are very handful. Thanks @kirillzyusko , we can close the issue :) |
Nice @elenydev Good luck with learning 😊 If you have any other questions - don't hesitate to open new issues, I'll be happy to answer all questions 😊 |
Describe the bug
Hey, i'm facing issue with
KeyboardAwareScrollView - When im trying to use it above the level of
FlatList` it does not work.Is there any specific way that i should handle it?
Of course, in the renderItem of flat list i does not have only the TextInput, but whole component with textInput in it
The text was updated successfully, but these errors were encountered: