I create two TouchableOpacity
in React Native
.
Code:
const App = () => {
const notification = [
{ id: 1, name: 'David Silbia', message: 'Invite Jo Malone London’s Mother’s', time: 'Just now' },
{ id: 2, name: 'Adnan Safi', message: 'Started following you', time: '20 min ago' },
{ id: 3, name: 'Ronald C. Kinch', message: 'Like you events', time: '9 hr ago' },
{ id: 4, name: 'Clara Tolson', message: 'Join your Event Gala Music Festival', time: 'Wed, 3:30 pm' },
]
return (
<View style={{flexDirection:'row'}}>
<TouchableOpacity
style={[styles.BellButton,{marginRight: 8,width: 50,}]}
onPress={() => navigation.navigate("Notification", {item:notification})}>
</TouchableOpacity>
<TouchableOpacity style={styles.BellButton}
onPress={() => navigation.navigate("Notification")}>
</TouchableOpacity>
</View>
)
}
export default App
On press 1st TouchableOpacity, it move to Notification page
with notification data
.
On press 2nd TouchableOpacity, it just move to Notification page
.
Notification page:
const Notification = ({ route }) => {
const navigation = useNavigation();
const { item } = route.params;
console.log(item)
return ()
}
export default Notification
The problem is I want to only send notification data
by pressing 1st TouchableOpacity
and on press 2nd TouchableOpacity
, it move to Notification page
and data is present there.
I solved my problem. The code is:
App
Notification