Pomax / react-onclickoutside

An onClickOutside wrapper for React components
MIT License
1.83k stars 187 forks source link

WrappedComponent lacks a handleClickOutside(event) function for processing outside click events. #303

Closed Robert-Fish closed 5 years ago

Robert-Fish commented 5 years ago
handleClickOutside = () => {
  console.log('hello world');
  };

export default connect(
  null,
  { toggleProject }
)(onClickOutside(ProjectDropdown));

I keep getting this error whenever i click on or near the component. "Uncaught Error: WrappedComponent lacks a handleClickOutside(event) function for processing outside click events."

Pomax commented 5 years ago

It looks like you tried to define a click handler in global scope, and that's not going to work.

As per the installation section in the README.md: either declare the handler as a normal function that's part of your ProjectDropdown class (first two examples), or make sure you have an options object with 'handleClickOutside' property and pass that into the wrapping function as second argument (third example).