I'm new to React Native. I made a simple app with the latest version in a functional component.
I'm trying to achieve on leftside icon onPress right side scroll to that element and this is two siblings in screen you can name it with left side screen and right side screen left side screen with style={{flex:1}} and rightside style={{flex:2}}
The left side has a list of 5 elements and right side screen have all 5 elements have 7 items on every list with title in a scroll view from react-native.
I want when the user clicks on the left side screen icon right side screen scrolls to the title position or something similar to that. The app is similar to when the user clicks on an item it scrolls to that item on the screen. I look into many tutorials not able to achieve what I'm trying to.
function leftside(){
<TouchableOpacity style={styles.left_container} onPress={itemA}>
<MaterialCommunityIcons
name={"itesname"}
size={35}
color={"#000"}
/>
<Text>Item</Text>
</TouchableOpacity>
<TouchableOpacity>
... till 5
</TouchableOpacity>
}
Right side:
import React from "react";
import { Text, View, Image } from "react-native";
function rightside({ uri, text }) {
return (
<View style={{ flexDirection: "column", backgroundColor: "#fff" }}>
<View
style={{
justifyContent: "center",
alignItems: "center",
paddingLeft: "5%",
}}
>
<Image
source={{
uri,
}}
style={{ width: 60, height: 80 }}
/>
<Text>{text}</Text>
</View>
</View>
);
}
export default rightside;
I tried to useRef and pass the ref to scroll view not work for me or maybe I'm approaching it in the wrong way.
any reference to any blog or post or solution appreciated it.! Image reference here..