SteffeyDev / react-native-popover-view

A well-tested, adaptable, lightweight <Popover> component for react-native
MIT License
613 stars 92 forks source link

Export `PublicPopoverProps` instead of `PopoverProps`? #148

Closed myou11 closed 2 years ago

myou11 commented 2 years ago

Describe the bug I am trying to create a default Popover component with my own custom popoverStyle and arrowSize so I dont have to repeat the same styles for each Popover usage. The PopoverProps in Typescript do not have the from prop, however, since the from prop is only specified on PublicPopoverProps which extends PopoverProps but is not exported as a type. So since I can't import PublicPopoverProps instead, I get a Property 'from' does not exist on type 'IntrinsicAttributes & PopoverProps'. Typescript error.

I'm wondering if it would make more sense to export PublicPopoverProps instead of PopoverProps since those are the props the Popover component is actually utilizing and the from prop is defined there.

Here is an example of my custom Popover I am trying to create:

import React from "react";
import Popover from "react-native-popover-view";
import { PopoverProps } from "react-native-popover-view/dist/Types";

const CustomPopover = (props: PopoverProps) => {
  const popoverStyle = { borderRadius: 8 };
  const popoverArrowSize = { width: 24, height: 12 };

  return (
    <Popover {...props} popoverStyle={popoverStyle} arrowSize={popoverArrowSize}>
      {props.children}
    </Popover>
  );
};

export default CustomPopover;

Then when I try to create a CustomPopover:

<CustomPopover
    isVisible={showPopover}
    onRequestClose={() => setShowPopover(false)}
    from={<SomeComponent />}
>
    <PopoverBody />
</CustomPopover>

Thank you for creating and maintaining this library!

Device/Setup Info:

SteffeyDev commented 2 years ago

Good idea, PublicPopoverProps are now exported in 5.1.7. Please re-open if this does not fix for you.

myou11 commented 2 years ago

Thanks @SteffeyDev! much appreciated and it worked!