react-native-masonry icon indicating copy to clipboard operation
react-native-masonry copied to clipboard

Duplicate images loaded

Open vvavepacket opened this issue 7 years ago • 12 comments

Version: 0.4.5

Expected Behavior

Images should be unique, no duplicate images should appear

Current Behavior

Currently, my bricks data only contains 2 unique images. I first initialize the bricks data to be an empty array, and then in the componentDidMount, I put 2 elements inside the array

constructor() {
        super();
        this.state = {
            tyu: []
        };
    }
componentDidMount() {
this.setState({
            tyu: [
                {
                    key: Math.floor((Math.random() * 100000000) + 1),
                    id: 0,
                    uri: 'https://img.purch.com/w/660/aHR0cDovL3d3dy5saXZlc2NpZW5jZS5jb20vaW1hZ2VzL2kvMDAwLzA5Ny85NTkvb3JpZ2luYWwvc2h1dHRlcnN0b2NrXzYzOTcxNjY1LmpwZw=='
                },
                {
                    key: Math.floor((Math.random() * 100000000) + 1),
                    id: 1,
                    uri: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Cat-eating-prey.jpg/220px-Cat-eating-prey.jpg'
                },
            ]
        })
}

image

Possible Solution

Steps to Reproduce

Sample code

<Masonry
                                            sorted={false} // optional - Default: false
                                            columns={2} // optional - Default: 2
                                            bricks={this.state.tyu}
                                            spacing={1}
                                            imageContainerStyle={{
                                                backgroundColor: '#DCDCDC'
                                            }}
                                        />

Context (Environment)

Detailed Description

Possible Implementation

vvavepacket avatar Mar 19 '18 13:03 vvavepacket

I'm having this issue too.

justinsayone avatar Mar 26 '18 10:03 justinsayone

@vvavepacket Just ran the exact code within the example repo, no issues on duplications. From the looks of the warning notifications it appears the parent component maybe rendering multiple times, which would make me believe there is some configuration issues with the navigators or tabs.

Maybe want to console within the components and react-native-masonry to make sure nothing funky is going on.

brh55 avatar Mar 28 '18 23:03 brh55

Confirmed on React Native v0.54.

@brh55 Why don't you test on recent versions? v0.46 looks pretty old.

mpyw avatar Apr 16 '18 12:04 mpyw

Hi, is 0.5.0 branch valid enough for using it / merging soon in master ?

lc3t35 avatar Jun 04 '18 12:06 lc3t35

@lc3t35 It is valid enough, I just been a bit busy with a start up to add some additional features I've been wanting to include with the release.

brh55 avatar Jun 04 '18 18:06 brh55

I'm having this issue too.

quasimodo1660 avatar Jun 08 '18 21:06 quasimodo1660

@brh55 when are you planning to merge version 0.5.0 in master. I am having duplicate images issue, single column render issue when images are cached (only first time works as expected) and sometimes images are left biased. Can you present some solution for now?

ahmedjamshed avatar Jun 10 '18 10:06 ahmedjamshed

Just published current state of v0.5.0 as an alpha prerelease (v0.5.0-alpha.1). I haven't properly tested this, so feel free to test this and report any issues.

An npm install should default to this pre-release.

brh55 avatar Jun 10 '18 21:06 brh55

@brh55 Duplicate image issue has been resolved on my side, but other two issues still persist. Although, single column render issue is not consistent on ios but consistent on android. I am attaching an image as a reference. Is there any quick fix for this? screen shot 2018-06-12 at 2 14 29 am

ahmedjamshed avatar Jun 12 '18 09:06 ahmedjamshed

@ahmedjamshed let's move this to a new thread for v0.5.0

brh55 avatar Jun 12 '18 17:06 brh55

@brh55 I fetch the data from my website api, then display them. My issue is after onPress into a details screen, the duplicate warning will appear. I am attaching some images to show the problem. at first simulator screen shot - iphone x - 2018-06-12 at 10 30 08 Press one negative to another screen simulator screen shot - iphone x - 2018-06-12 at 10 48 33 go back to home page simulator screen shot - iphone x - 2018-06-12 at 10 36 18

quasimodo1660 avatar Jun 12 '18 17:06 quasimodo1660

There is a known issue if all bricks haven't resolved completely, and there is a state change, a duplicated request will be made for the bricks that have not been placed. Haven't seemed to find a good way to get around this, while preventing a full reload.

brh55 avatar Jun 12 '18 21:06 brh55