2018-09-23 18:40:18 -04:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
|
import uuid from 'uuid/v4'
|
|
|
|
|
|
|
|
|
|
export default BaseComponent => {
|
|
|
|
|
class WithCacheBust extends Component {
|
|
|
|
|
state = { bust: '?bust' }
|
|
|
|
|
|
|
|
|
|
onPressReload = () => {
|
|
|
|
|
// Force complete re-render and bust image cache.
|
|
|
|
|
const key = uuid()
|
|
|
|
|
const bust = `?bust=${key}`
|
|
|
|
|
this.setState({ bust })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<BaseComponent
|
|
|
|
|
bust={this.state.bust}
|
|
|
|
|
onPressReload={this.onPressReload}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-25 01:11:47 -05:00
|
|
|
WithCacheBust.displayName = `withCacheBust(${BaseComponent.displayName ||
|
|
|
|
|
BaseComponent.name})`
|
2018-09-23 18:40:18 -04:00
|
|
|
|
|
|
|
|
return WithCacheBust
|
|
|
|
|
}
|