brh55 / react-native-masonry

:raised_hands: A pure JS react-native component to render a masonry~ish layout for images with support for dynamic columns, progressive image loading, device rotation, on-press handlers, and headers/captions.
MIT License
1.32k stars 157 forks source link

How to navigate from one of the bricks using this.props.navigation #84

Closed SABRYX closed 6 years ago

SABRYX commented 6 years ago

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce

Context (Environment)

Detailed Description

Possible Implementation

brh55 commented 6 years ago

@SABRYX Add an .onPress to all of your brick objects ({ onPress: () => navigate('item1') }). Here's a way to dynamically do this using .map.

const addOnPress = (item) => {
    item.onPress = () => this.props.navigate(item.data.name)
};

const data = [
    {data: {name: 'page 1'}, uri: '...'},
    {data: {name: 'page 2', uri: '...'},
    {data: {name: 'page 3', uri: '...'}
].map(addOnPress);
SABRYX commented 6 years ago

@brh55 thanks for the response i'll try it