Skip to content

Instantly share code, notes, and snippets.

@goldhand
Created May 19, 2016 14:53
Show Gist options
  • Save goldhand/2c1af2651f79f3b8953054b46307348f to your computer and use it in GitHub Desktop.
Save goldhand/2c1af2651f79f3b8953054b46307348f to your computer and use it in GitHub Desktop.
An idea for loading large image files. Shouldn't update the state in componentDidMount though. Worried loading the white bg then loading another image right away will lead to thrashing
// currentBG = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs='; // single white pixel
componentDidMount() {
// set background image after compnent has been built
this.setState({
...this.state,
styles: {
...this.state.styles,
backgroundImage: `url(${this.props.background})`,
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment