question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avatar Background Image Flashing Grey

See original GitHub issue

Issue- when I type into handle change basically every time it re-renders the overlayContainerStyle every time. I am able to switch to just image and it will never re-render, but I would like to use the avatar and edit badge. I included a video attachment with what is going on

Versions:

“react-native-elements”: “^1.2.0”, “react-native”: “0.60.5”,

Video of issue:

https://vimeo.com/user105102986/review/372705871/7aa951b3a3

Code:

WHERE THE ISSUES IS:

<Avatar
                  size="xlarge"
                  rounded
                  source={{ uri: this.state.profilePicture }}
                  showEditButton
                />

Full code

import React, { Component } from "react";
import { connect } from "react-redux";
import {
  updateProfilePhoto,
  updateUserInformation,
  loadCurrentUserProfile
} from "../../../store/profile/actions";
import { loadCurrentUser } from "../../../store/chat/actions";

import {
  Text,
  TextInput,
  View,
  SafeAreaView,
  ScrollView,
  ActivityIndicator,
} from "react-native";
import { Avatar } from "react-native-elements";
import styles from "./Styles";

class EditProfileComponent extends Component {
  constructor(props) {
    super(props);

    this.state = {
      description: this.props.currentUser.about,
      profilePicture: this.props.currentUser.profilePicture,
    };

    this.handleDescriptionChange = description => {
      this.setState({ description });
    };
  }

  componentDidMount() {
    this.props.updateProfilePhoto;
    this.props.updateUserInformation;
    this.props.loadCurrentUser;
  }

  componentDidUpdate(prevProps) {
    if (this.props.photoUrl && prevProps.photoUrl !== this.props.photoUrl) {
      this.setState({ profilePicture: this.props.photoUrl });
    }
  }

  
  render() {
    const { username, loadingProfilePicture } = this.props;
    const {
      header,
      flex1,
      safeAreaView,
      label,
      descriptionContainer,
      descriptionText,
      characterCount,
    } = styles;
    return (
      <SafeAreaView style={safeAreaView}>
        <View style={flex1}>
          <ScrollView style={flex1}>
            <View style={header}>
              {!loadingProfilePicture ? (
                <Avatar
                  size="xlarge"
                  rounded
                  source={{ uri: this.state.profilePicture }}
                  showEditButton
                />
              ) : (
                <ActivityIndicator />
              )}
              <Text style={styles.username}>{username}</Text>
            </View>
            <View style={flex1}>
              <Text style={label}>ABOUT ME:</Text>
              <View style={descriptionContainer}>
                <TextInput
                  multiline={true}
                  numberOfLines={10}
                  onChangeText={this.handleDescriptionChange}
                  value={this.state.description}
                  placeholder="Tell everyone about your riding style, 
                  favorite mountains, what makes you unique, etc.."
                  editable={true}
                  maxLength={300}
                  style={descriptionText}
                />
              </View>
              {this.state.description ? (
                <Text style={characterCount}>
                  Characters Count: {this.state.description.length}/300
                </Text>
              ) : null}
            </View>
          </ScrollView>
        </View>
      </SafeAreaView>
    );
  }
}

const mapStateToProps = state => ({
  loadingProfilePicture: state.profile.loadingProfilePicture,
  loadingProfileDescription: state.profile.loadingProfileDescription,
  currentUser: state.chat.currentUser,
  loading: state.chat.loadCurrentUser,
  photoUrl: state.profile.photoUrl,
  interests: state.profile.interests,
  currentUserProfile: state.profile.currentUserProfile
});

const mapDispatchToProps = {
  updateProfilePhoto,
  updateUserInformation,
  loadCurrentUser,
  loadCurrentUserProfile
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(EditProfileComponent);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
iRoachiecommented, Nov 27, 2019

Avatar already supports this by use of the imageProps prop

2reactions
iRoachiecommented, Nov 27, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Background keeps flashing while in game?! : r/Vive - Reddit
Background flickering is caused by either dropped frames or loss of tracking quality. I'd imagine most of your problems are caused by loosing...
Read more >
Why is my background image disappearing/flickering ...
The image will flicker in and out a bit before permanently being replaced with the gray background. Here is my HTML:
Read more >
500+ Flash Images | Download Free Pictures on Unsplash
Download the perfect flash pictures. Find over 100+ of the best free flash images. ... Unsplash logo. Avatar of user Getty Images.
Read more >
macos - Sudden flash of gray in the background - Ask Different
In the last few days I've had a sudden flash of gray in the background. I'm on MacOS 10.7.5. I'm not able to...
Read more >
The Complete Guide to Lazy Loading Images | CSS-Tricks
In short, a gray placeholder box is rendered on the page until it scrolls into view—at ... Chapter 4: Lazy Loading CSS Background...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found