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

the masonry view is blank when i add data to state.data

Open chienvu123 opened this issue 6 years ago • 9 comments

i use Example at lib, when i click push new data, view is removed

anyone help me, please!


i use version 0.5.0

chienvu123 avatar Nov 29 '18 16:11 chienvu123

same problem here, since I tried to load next page when grid end reached

trungnt85 avatar Dec 07 '18 16:12 trungnt85

I get this error on a dynamic data what I did to fix this is to rerender by using state.. so heres the thing... you need to rerender it to work

add a boolean state that changes when you add a new data to the masonry view

example when you add a data... setState({ itemsLoaded: false }); after data was added setState({ itemsLoaded: true });

if(this.state.itemsLoaded) {
      return (
        <View style={{
          flex: 1,
          padding: 10,
          paddingBottom: 80,
          backgroundColor: '#f5f6fa',
        }}>
          <Masonry
            bricks={this.state.items}
            sorted
            spacing={6}
            columns={2}
            customImageComponent={CustomImage}
            imageContainerStyle={{
              paddingTop: 10,
              backgroundColor: '#ffffff',
              borderTopLeftRadius: 10,
              borderTopRightRadius: 10,
            }}
          />
        </View>
      );
    }
    else {
      return (
        <View>
            <Text>Loading Data..</Text>
        </View>
      );
    }

you get what I mean?

logicallyDimp avatar Dec 10 '18 06:12 logicallyDimp

@logicallyDimp it's not working for me

 if (this.state.loading) {
      return (
        <View style={styles.ClusterListBoxEmpty}>
          <ActivityIndicator animating={true} color="#242424" size="large" />
          <Text style={styles.textTitleEmpty}>
            Aquí aparecerán las fotos y videos que tomes con Picnow
          </Text>
        </View>
      );
    }
    if (Object.keys(this.state.ClusterAll).length === 0) {
      return (
        <View style={styles.ClusterListBoxEmpty}>
          <Text style={styles.textTitleEmpty}>No has tomado ninguna foto.</Text>
        </View>
      );
    } else if (Object.keys(this.state.ClusterAll).length > 0) {
      let uri = [];
      this.state.ClusterAll.map(({ view }) => {
        uri.push({ uri: view });
      });
      console.log(uri);
      return (
        <View style={styles.ClusterListBox}>
          <Masonry
            sorted
            columns={3} // optional - Default: 2
            bricks={uri}
          />
        </View>
      );
    }

DanthonyPabon avatar Dec 19 '18 21:12 DanthonyPabon

have you tried doing it like this?

if(this.state.loading) {
	return (
		<View style={styles.ClusterListBoxEmpty}>
			<ActivityIndicator animating={true} color="#242424" size="large" />
			<Text style={styles.textTitleEmpty}>
				Aquí aparecerán las fotos y videos que tomes con Picnow
			</Text>
		</View>
	);
}
else {
	if (Object.keys(this.state.ClusterAll).length === 0) {
		return (
			<View style={styles.ClusterListBoxEmpty}>
				<Text style={styles.textTitleEmpty}>No has tomado ninguna foto.</Text>
			</View>
		);
	} else if (Object.keys(this.state.ClusterAll).length > 0) {
		let uri = [];
		this.state.ClusterAll.map(({ view }) => {
			uri.push({ uri: view });
		});
		console.log(uri);
		return (
			<View style={styles.ClusterListBox}>
				<Masonry
					sorted
					columns={3} // optional - Default: 2
					bricks={uri}
				/>
			</View>
		);
	}
}

logicallyDimp avatar Dec 20 '18 04:12 logicallyDimp

@logicallyDimp the first time it renders it does show up as masonry, but the second time it renders it does not as masonry

Whats-App-Image-2018-12-20-at-10-00-31-AM

DanthonyPabon avatar Dec 20 '18 14:12 DanthonyPabon

same thing for me, have you solved it?

Richi2293 avatar Mar 11 '19 10:03 Richi2293

I don't using it

DanthonyPabon avatar Mar 15 '19 22:03 DanthonyPabon

So I looked into this issue a while back, it really stems from an async call to load the image, but doesn't complete before the masonry view changes. This causes the masonry to run into a runtime exception and stops loading completely. If anyone wants to try to fix this to integrate cancellable async calls, this should fix the issue (almost certain).

brh55 avatar Mar 22 '19 15:03 brh55

I still encounter the same issue when appending new data to the list, anyone has a quick fix to it ?

Abdelrahman-Nabil avatar May 28 '19 07:05 Abdelrahman-Nabil