-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create the property holdPlaceholder to keep the placeholder for some … #55
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (!this.props.firstLaunchOnly && this.state.ready && !nextProps.ready) { | ||
this.setNotReady(); | ||
if (!this.props.firstLaunchOnly && !nextProps.ready) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this new code over complicated and difficult to read...
Why didn't you use the two functions setReady
and setNotReady
already implemented?
we already have a state variable called ready
to decide if we should render the placeholder or the content => I don't see the need of the new this.state.holdPlaceholder
variable
|
||
componentWillMount() { | ||
if (this.props.holdPlaceholder > 0) { | ||
this.holdPlaceholderTimeout = setTimeout(() => this.setState({ holdPlaceholder: false }), this.props.holdPlaceholder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you always setting a timeout? shouldn't it be added only if this.state.ready
(which is initialized to this.props.ready
) is true
?
@@ -80,14 +83,28 @@ export default class ReactPlaceholder extends React.Component { | |||
} | |||
|
|||
render() { | |||
return this.state.ready ? this.props.children : this.getFiller(); | |||
const { ready, holdPlaceholder } = this.state; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have ready
, can't see the need for another variable that does the same thing
The opposite from
delay
, to keep the placeholder for some milliseconds even after the content is readySee #54