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

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

Open
Zeikko opened this issue Mar 3, 2021 · 3 comments
Open

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

Zeikko opened this issue Mar 3, 2021 · 3 comments

Comments

@Zeikko
Copy link
Contributor

Zeikko commented Mar 3, 2021

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?

@tomzaku
Copy link
Owner

tomzaku commented Mar 4, 2021

Interesting. But this is the edge case. Let's see if anyone really needs this.
As I know you can handle it from your side right

@Zeikko
Copy link
Contributor Author

Zeikko commented Mar 4, 2021

Yes we do handle this from our side and it is working fine. Let's see if someone else needs this as well.

@tomzaku
Copy link
Owner

tomzaku commented Mar 4, 2021

Thank you. Please don't close this issue.

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

No branches or pull requests

2 participants