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

[Typings] Can't assign Element to customPlaceholder #75

Closed
patrykgulas opened this issue May 24, 2018 · 1 comment
Closed

[Typings] Can't assign Element to customPlaceholder #75

patrykgulas opened this issue May 24, 2018 · 1 comment

Comments

@patrykgulas
Copy link

When I try to pass Element to customPlaceholder prop it returns following type error:

Type 'element' is not assignable to type 'undefined'.

    const awesomePlaceholder = (
      <div>
        <RectShape color="blue" style={{width: 30, height: 80}}/>
        <TextBlock rows={7} color="yellow"/>
      </div>
    );

    return (
      <ReactPlaceholder
        type="rect"
        showLoadingAnimation={true}
        customPlaceholder={awesomePlaceholder}
        ready={!isLoading}
      >
    )

Also, type prop is required but we shouldn't pass it using customPlaceholder. Is it something to fix or I'm doing something wrong?

@gabro
Copy link
Member

gabro commented May 24, 2018

The error is a bit confusing, but essentially you need to skip type and showLoadingAnimation. Since you're passing a custom placeholder, those two props don't apply anymore.

This is specified as a union type in the props definitions.

Essentially this should typecheck fine:

<ReactPlaceholder
  customPlaceholder={awesomePlaceholder}
  ready={!isLoading}
/>

Closing the issue, as this should solve it, feel free to comment here if you have further problems and we can re-open it.

@gabro gabro closed this as completed May 24, 2018
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