Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reactjs wait for image to load from url

class Foo extends React.Component {
  constructor(){
    super();
    this.state = {loaded: false};
  }

  render(){
    return (
      <div>
        {this.state.loaded ? null :
          <div
            style={{
              background: 'red',
              height: '400px',
              width: '400px',
            }}
          />
        }
        <img
          style={this.state.loaded ? {} : {display: 'none'}}
          src={this.props.src}
          onLoad={() => this.setState({loaded: true})}
        />
      </div>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript target closest class 
Javascript :: run javascript in flutter 
Javascript :: javascript test if undefined 
Javascript :: update password using comparePassword() Method 
Javascript :: javascript find method 
Javascript :: how to give placeholder in input type date in angular 
Javascript :: opposite number js 
Javascript :: dropdown item from the list flutter 
Javascript :: javascript tousand seperator 
Javascript :: javascript optional parameters 
Javascript :: get list of filenames in folder 
Javascript :: in in sequelize 
Javascript :: phaser generate frame numbers 
Javascript :: nuxt history back 
Javascript :: .env file example react native 
Javascript :: joi not empty string 
Javascript :: show ad on facebook game 
Javascript :: how to access variables in a different script file 
Javascript :: vue js data bind 
Javascript :: javascript tag 
Javascript :: sleep 1 second 
Javascript :: vue.js props undefined type 
Javascript :: compare if strings are equal javascript 
Javascript :: loadstring json flutter 
Javascript :: Assume that x is a char variable has been declared and already given a value. Write an expression whose value is true if and only if x is a upper-case letter. 
Javascript :: react js require pasword to have special charaacter 
Javascript :: dotenv in node js 
Javascript :: jquery steps disable finish button 
Javascript :: get parent class javascript 
Javascript :: add href to image javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =