18

I am using react-click-outside to hide dropdown menus if the user clicks outside the menu. Normally, I would export the component like so:

export default enhanceWithClickOutside(Dropdown);

However, in this case, I want to export the component

export { enhancedWithClickOutside(Dropdown) };

But that apparently does not work. Is there a way to export using {} and also apply the higher order component function?

davidhu
  • 9,523
  • 6
  • 32
  • 53

1 Answers1

30
export class Dropdown extends React.component {
  ...
}

export const EnhancedDropdown = enhanceWithClickOutside(Dropdown);

Somewhere else

import { Dropdown, EnhancedDropdown } from 'path/to/Dropdown';
Andy_D
  • 4,112
  • 27
  • 19