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

Hey, I'm having some troubles when i need to change styles for an item inside on flashlist #1000

Open
lucasFigueira1 opened this issue Dec 15, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@lucasFigueira1
Copy link

lucasFigueira1 commented Dec 15, 2023

I recently replaced a FlatList with FlashList, which contains a couple of buttons. One of them used to change its background color and text color upon being pressed. However, since I've switched to using FlashList, this functionality is no longer working.

`<>
<FlashList
estimatedItemSize={100}
showsVerticalScrollIndicator={false}
data={selectedCluster}
renderItem={({ item }) => {
const isDirectionsVisible = showDirectionsMap[item._id] || false;
return (
<View style={{ backgroundColor: '#fff', paddingHorizontal: width * 0.07, paddingVertical: height * 0.01, gap: height * 0.01 }}>
<MapContactCard
onContactCardPress={() => centerMapOnMarker(item)}
selectedMarker={item}
auth={auth}
/>

            <View style={{
              flexDirection: 'row',
              justifyContent: 'space-between',
              alignItems: 'center',
              gap: 8,
            }}>
              <SelectedMarkerCardButton
                bgColor={isDirectionsVisible ? '#1877F2' : '#fff'}
                label={isDirectionsVisible ? 'Ocultar' : 'Ver ruta'}
                labelColor={isDirectionsVisible ? '#fff' : '#4B5563'}
                icon={<Ionicons
                  name="map"
                  color={isDirectionsVisible ? '#fff' : '#4B5563'}
                  size={height * 0.022}
                />}
                onPressSelectedMarkerCardButton={() => {
                  setPolylineColor(item);
                  setShowDirectionsMap((prevState: any) => ({
                    ...prevState,
                    [item._id]: !isDirectionsVisible,
                  }));
                  debounceDirectionsApi(
                    {
                      latitude: item?.contactLocation.geoLocation.coordinates[1],
                      longitude: item?.contactLocation.geoLocation.coordinates[0],
                    },
                    currentLocation,
                    auth?.user._id,
                  );
                }
                }
              />
            </View>
          </View>
        );
      }}
    />
  </>`
@lucasFigueira1 lucasFigueira1 added the bug Something isn't working label Dec 15, 2023
@switz
Copy link

switz commented Dec 19, 2023

Are you using stickyHeaderIndices - I found removing it "solved" this bug for me. Something is wonky there

@RattyJhay
Copy link

I'm also having the same problem, my onPress isn't working.

@arditderstila
Copy link

arditderstila commented May 10, 2024

its a bit late as response but i solved this way:

 const [active_index, setactive_index] = useState(0);

    const handleTabPress = (index, location) => {
        setactive_index(index);
    };

    const keyExtractor = useCallback((item) => item.id.toString(), [active_index]);

    const renderItem = ({ item, index }) => (
        <TabsItem
            item={item}
            index={index}
            sendePressEvent={handleTabPress}
            active_index={active_index}
        />
    );

    return (
        <View style={styles.mainContainer}>
            <FlashList
                data={gymClasses}
                extraData={active_index}
                estimatedItemSize={77}
                showsHorizontalScrollIndicator={false}
                horizontal
                keyExtractor={keyExtractor}
                renderItem={renderItem}
            />
        </View>
    );

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

4 participants