Closed chiefGui closed 5 years ago
I get the error below is there any fix for it?
Type 'Element' is not assignable to type '(args: { isVisible: boolean; visibilityRect?: Shape | undefined; }) => any
@imkimchi Can I see your component and its props, please?
<VisibilitySensor onChange={isVisible => onWidgetSectionVisible(isVisible, 0)} intervalDelay={50}>
<SectionTitle> something </SectionTitle>
</VisibilitySensor>
I guess the children type problem occurs when children of VisibilitySensor
is made with styled-components
.
I fixed by changing children
type to JSX.Element
children?: JSX.Element;
Oh, okay, I see your problem but that's not the most accurate solution given the current definition file. You could make it work this way:
<VisibilitySensor>
{() => <SectionTitle />}
</VisibilitySensor>
Thing is, you're right. The definition should support non-render-props signature. I'll be updating it, thanks for the heads up!
Okay @imkimchi - you can try it now. It'll work with both children signature fashions.
Thanks @chiefGui and everyone for collaborating on this!
Published as v5.1.0
Fixes https://github.com/joshwnj/react-visibility-sensor/issues/112
Kudos to @asborisov at https://github.com/joshwnj/react-visibility-sensor/issues/112#issuecomment-413869897 for releasing the initial version of this type definition.
Please, let me know if there's something that doesn't work.