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 use Masorny customImageComponent? #90

Closed kkotkkio closed 6 years ago

kkotkkio commented 6 years ago

I read README.md .

And I wrote below.

import React, { Component } from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
import Masonry from 'react-native-masonry';
import FastImage from 'react-native-fast-image';

const data = [
  {
    uri: 'https://unsplash.it/400/400?image=1',
    priority: FastImage.priority.normal,
    style: { width: 300, height: 300 }
  }
];

const fastProps = {
  onProgress: e => { console.log(e.nativeEvent.loaded / e.nativeEvent.total) },
  resizeMode: FastImage.resizeMode.contain
};

class HomeScreen extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <View>

        <FastImage
          style={s.image}
          source={{
            uri: 'https://unsplash.it/400/400?image=1',
            headers:{ Authorization: 'someAuthToken' },
            priority: FastImage.priority.normal,
          }}
          resizeMode={FastImage.resizeMode.contain}
        />  <<<<<<<<<<<<<<<<<<< **_this is well._**

        <Masonry
          bricks={data}
          customImageComponent={FastImage}
          customImageProps={fastProps} />  **_<<<<<<<<<< this is not showing on screen_**

      </View>
    );
  }
}

export default HomeScreen;

const s = StyleSheet.create({
  image: {
    width: 300,
    height: 300
  }
});

First, I try to use FastImage single like below. <FastImage> This work well.

But I try to use FastImage with Masonry (customImageComponent) , this is not showing.

I'd like to know detail how to use customImageComponent.

Needs help.

Thank you :)

kkotkkio commented 6 years ago

I think of this problem was didn't styling so how to apply some 'style' in customImageComponent?

brh55 commented 6 years ago

@kkotkkio I would suggest following the example, the example is using FastImage ^_^