react native - ReactNative Image | setNativeprops unable to change source -


i have implemented image onerror method network image , in error trying update view default image source property have no effect

onloaderror=(event)=>{      alert('img load error');      this.imgpayicn.setnativeprops({        source :{uri:'https://facebook.github.io/react/img/logo_og.png'} //not able update view new image... no effect        }); 

render method

<image ref={(ref) => this.imgpayicn = ref} source={this.props.source} style={{height:50,width:50}} resizemode='cover' onerror={this.onloaderror}/> 

wrap image in component handles error:

class imagewithfallback extends component {   state = {     failed: false,   }    render() {     if (this.state.failed) {       return <image source={require('imagefallback.png')} />     }     return <image {...this.props} onerror={() => this.setstate({ failed: true })} />   } } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -