Closed FrSenpai closed 3 months ago
@FrSenpai
What if you try keyExtractor={(item, i) => i}
?
Looks like you're passing base64 as a key in your example
@FrSenpai How do you use renderItem?
Same result with keyExtractor. Even if I'm removing renderItem, same result.
const renderItem = ({
item,
setImageDimensions,
}: RenderItemInfo<{uri: string}>): React.JSX.Element => {
return (
<Image
source={{uri: item.uri}}
style={StyleSheet.absoluteFillObject}
resizeMode="contain"
onLayout={e => {
const {width, height} = e.nativeEvent.layout
console.log('LAYOUT', width, height)
setImageDimensions({width, height})
}}
/>
)
}
@FrSenpai You should get image dimensions from onLoad, not from onLayout
onLoad={(e) => { const { width, height } = e.nativeEvent.source; setImageDimensions({ width, height }); }}
Tried it too, and even onLoadEnd seems not work I'll try with FastImage, to check if it's related to Image of React Native
"react-native": "0.72.5", "react-native-reanimated": "^3.6.1",
Can it be related with not using flex ?
Okay, it's definitly related of not using flex.
I don't think it should be required, but I understand that can be hard to avoid it
@FrSenpai I think your GestureHandlerRootView should have style={{flex: 1}}
`const MediaModalScreen = ({ media, index = 0, }: { media: PublicationMetadataMedia[]; index?: number; }) => { useStatusBarStyle('light-content'); const {goBack} = useAppNavigation(); const {scrollY, tabHeight} = useBottomTabView(); const screenSize = useScreenDimensions();
useFocusEffect( useCallback(() => { if (scrollY.value < tabHeight) { scrollY.value = withTiming(tabHeight); } }, [scrollY, tabHeight]), );
const {top} = useSafeAreaInsets();
const shareIndex = useSharedValue(index);
const total = useMemo(() => { return media ? media.length : 0; }, [media]);
const curCount = useDerivedValue(
() => ${shareIndex.value + 1} / ${total}
,
[total],
);
const renderItem = useCallback(
({
item,
index: idx,
setImageDimensions,
}: RenderItemInfo
); };
export default MediaModalScreen;
const RenderItem = ({
item,
share,
setImageDimensions,
}: RenderItemInfo
const url = useMemo( () => getUrlIfIpfs(getImageUriFromMetadata(item)), [item], );
const style = useMemo(() => { return { width: dimension.width, height: Math.min((dimension.width / width) * height, dimension.height), }; }, [dimension, width, height]);
return (
); }; `I'm having the same issue
please help
You should remove alignItems: 'center'
out of View, that includes your Gallery and add
style={{flex: 1}}
to GestureHandlerRootView
Code example with the same problem:
export default function App() {
return (
<GestureHandlerRootView>
<View style={styles.container}>
<MyGallery/>
<StatusBar style="auto" />
</View>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Working code example:
export default function App() {
return (
<GestureHandlerRootView style={{flex: 1}}>
<View style={styles.container}>
<MyGallery/>
<StatusBar style="auto" />
</View>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
},
});
Hey again!
I'm not using expo image, I don't know if it can be related, but when I've got more than 1 image into my data, it's not showing correctly the gallery content.
My component:
I'm using the same boilerplate as the example provided, tried a lot of params (played with loop, numToRender, onLoadEnd, onLoad, and more) but same result. But it's working perfectly when there is only 1 image.
I'm probably missing something, I'm sorry about it... Have a nice day!