Pomax / react-onclickoutside

An onClickOutside wrapper for React components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-onclickoutside does not export default props of wrapped component

psekaruipath opened this issue · comments

Issue:

I have a component A with default propA which is wrapped inside onClickOutside HOA like so,

class ComponentA extends React.Component {
  static defaultProps {
    propA: true,
  }
  ....
}

export default onClickOutside(ComponentA)

When I am using this component in another component, componentA.props.propA is undefined instead of true.

When I look at the code, I see that it is not merging wrapped component's default props with its own default props.

My workaround for the issue:
I have a work around in my code which wraps this wrapped component and that exposes the same default props. It is not the correct fix but it unblocked me for now.

Bug Fix Request:
Right place to add that logic is in your library so the wrapped component's default props plus the library's default props are exported properly.

commented

This should probably be fixed with the React 16+ forwardRef system, in a v7 with the current system of manually figuring out what's being wrapped getting relegated to a deprecated 6.x