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

Data Duplication issue using react-hook-form #1449

Open
2 tasks done
amjadbouhouch opened this issue Dec 13, 2024 · 3 comments
Open
2 tasks done

Data Duplication issue using react-hook-form #1449

amjadbouhouch opened this issue Dec 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@amjadbouhouch
Copy link

Current behavior

I have a list of questions and answers (Q/A) where the state is managed by react-hook-form. When there are many questions and the user scrolls, the answers get duplicated in the UI. For example, the answer for the first question appears again in a later question, even though the underlying data is correct.

Here’s a reproduction of the issue: https://snack.expo.dev/@amjedbouhouch/react-hook-form-flash-list-issue?platform=android

ScreenShots

Image Image

Expected behavior

To Reproduce

https://snack.expo.dev/@amjedbouhouch/react-hook-form-flash-list-issue?platform=android

Platform:

  • iOS
  • Android

Environment

1.6.4

@amjadbouhouch amjadbouhouch added the bug Something isn't working label Dec 13, 2024
@amjadbouhouch
Copy link
Author

amjadbouhouch commented Dec 14, 2024

Adding a key in ItemComponent solves the problem, But this is not what I want because I think it has a performance Impact & forces React to unmount and remount.

@krishnan-456
Copy link

krishnan-456 commented Mar 4, 2025

I have rendered a list of 10 TextInput fields. When I focus on the last TextInput and scroll up, I notice that the focus is also applied to the first rendered TextInput. Does anyone faced this issue?

"@shopify/flash-list": "^1.7.1",
"react-native": "^0.75.5"

@krishnan-456
Copy link

krishnan-456 commented Mar 4, 2025

I have rendered a list of 10 TextInput fields. When I focus on the last TextInput and scroll up, I notice that the focus is also applied to the first rendered TextInput. Does anyone faced this issue?

"@shopify/flash-list": "^1.7.1", "react-native": "^0.75.5"

import React from 'react'
import { View, TextInput, StyleSheet } from 'react-native'
import { FlashList } from '@shopify/flash-list'

const App = () => {
  const data = Array.from({ length: 40 }, (_, index) => ({
    key: index.toString(),
    question: `Question ${index + 1}`,
  }));

  // Render each TextInput
  const renderItem = ({ item }: { item: { question: string; answer: string } }) => (
    <View style={styles.itemContainer}>
      <TextInput
        style={styles.input}
        placeholder={item.question}
      />
    </View>
  );

  return (
    <View style={styles.container}>
      <FlashList
        data={data}
        renderItem={renderItem}
        keyExtractor={(item) => item.key}
        estimatedItemSize={50}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 16,
  },
  itemContainer: {
    marginBottom: 10,
  },
  input: {
    height: 40,
    borderColor: 'gray',
    borderWidth: 1,
    paddingHorizontal: 8,
  },
});

export default App;

video attached below:
https://github.com/user-attachments/assets/4b838433-5fe4-4c81-8552-154b3fca1640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants