Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fabiopaiva
Copy link
Contributor

@fabiopaiva fabiopaiva commented Oct 30, 2017

The opposite from delay, to keep the placeholder for some milliseconds even after the content is ready

See #54

}

componentWillReceiveProps(nextProps) {
if (!this.props.firstLaunchOnly && this.state.ready && !nextProps.ready) {
this.setNotReady();
if (!this.props.firstLaunchOnly && !nextProps.ready) {
Copy link
Contributor

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);
Copy link
Contributor

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;
Copy link
Contributor

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

@nemobot nemobot added WIP and removed in review labels Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants