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

Fix mobile version of ReviewList on the example demo #4878

Merged
merged 1 commit into from
Jun 3, 2020

Conversation

alanpoulain
Copy link
Contributor

@alanpoulain alanpoulain commented May 30, 2020

Checking the loading prop for rendering the SimpleList was wrong, it should be !loading or loaded.

The ReviewMobileList component in the demo has also been fixed (it's coming from the SimpleList component).

@alanpoulain alanpoulain force-pushed the fix-simple-list-loading branch 2 times, most recently from c2dd003 to 76281b1 Compare May 30, 2020 13:26
@fzaninotto
Copy link
Member

In SimpleList, at that stage, the loaded prop is always true, because of the previous test:

    if (loaded === false) {
        return (
            <SimpleListLoading
                classes={classes}
                className={className}
                hasLeftAvatarOrIcon={!!leftIcon || !!leftAvatar}
                hasRightAvatarOrIcon={!!rightIcon || !!rightAvatar}
                hasSecondaryText={!!secondaryText}
                hasTertiaryText={!!tertiaryText}
            />
        );
    }

    return (
        (loading || total > 0) && (
            <List className={className} {...sanitizeListRestProps(rest)}>
...

So a test for the loaded value is useless.

The question is: is the test for the loading value useful? There is a case where both loading and loaded can be true: when fetching the data for the list after it's already been rendered once (i.e. when coming back to a list page already viewed). The current test forces the display of the list in that case even though the total is null. I don't see the point.

So you can remove the test on the loading value altogether in SimpleList.

I agree with the change on ReviewListMobile.

Use loaded instead of loading.
The ReviewMobileList component in the demo has also been fixed (it's
coming from the SimpleList component).
@fzaninotto fzaninotto changed the title SimpleList was using the wrong loading prop Fix mobile version of ReviewList on the example demo Jun 3, 2020
@fzaninotto fzaninotto merged commit 3d245df into marmelab:master Jun 3, 2020
@fzaninotto
Copy link
Member

Thanks!

@fzaninotto fzaninotto added this to the 3.5.6 milestone Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants