Browse Source
This reduce amount of blinks - but not prevent them completely in dev So still need investigatemaster
meriadec
7 years ago
3 changed files with 50 additions and 97 deletions
@ -1,40 +0,0 @@ |
|||
// @flow
|
|||
|
|||
import { PureComponent } from 'react' |
|||
|
|||
type Props = { |
|||
children: any, |
|||
} |
|||
|
|||
type State = { |
|||
shouldRender: boolean, |
|||
} |
|||
|
|||
class Defer extends PureComponent<Props, State> { |
|||
state = { |
|||
shouldRender: false, |
|||
} |
|||
|
|||
componentDidMount() { |
|||
this._mounted = true |
|||
|
|||
window.requestAnimationFrame(() => |
|||
window.requestAnimationFrame(() => this._mounted && this.setState({ shouldRender: true })), |
|||
) |
|||
} |
|||
|
|||
componentWillUnmount() { |
|||
this._mounted = false |
|||
} |
|||
|
|||
_mounted = false |
|||
|
|||
render() { |
|||
const { children } = this.props |
|||
const { shouldRender } = this.state |
|||
|
|||
return shouldRender ? children : null |
|||
} |
|||
} |
|||
|
|||
export default Defer |
Loading…
Reference in new issue