Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chienvu123 opened this issue Nov 29, 2018 · 9 comments
Open

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

chienvu123 opened this issue Nov 29, 2018 · 9 comments

Comments

@chienvu123
Copy link

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

anyone help me, please!


i use version 0.5.0

@trungnt85
Copy link

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

@logicallyDimp
Copy link

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?

@DanthonyPabon
Copy link

@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>
      );
    }

@logicallyDimp
Copy link

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>
		);
	}
}

@DanthonyPabon
Copy link

DanthonyPabon commented Dec 20, 2018

@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

@Richi2293
Copy link

same thing for me, have you solved it?

@DanthonyPabon
Copy link

I don't using it

@brh55
Copy link
Owner

brh55 commented Mar 22, 2019

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).

@Abdelrahman-Nabil
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants