Skip to content

Shimmer container is rendered even with null / false children #58

@Zeikko

Description

@Zeikko

I'm experiencing a situation where the shimmer is container View is rendered even when the children is null / false.
I expected the shimmer container view not to be rendered when children is null / false.
This causes the shimmer to reserve space according to its height and width even when there is nothing to render.

Example JSX:

<ShimmerPlaceholder visible={!loading}>
  {Boolean(data) && <Text>{data}</Text>}
</ShimmerPlaceholder>

In case where loading is false but data is falsy, this JSX render an empty View. I think it would be better to not render anything in this case. I think this could be changed by adding the following code to the BaseShimmerPlaceholder

if (visible && (children === null || children === false)) {
  return null
}

Is this an issue or a design decision that has been made? Is my proposed fix feasible or are there some issues with it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions