Pomax / react-onclickoutside

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

ReferenceError: performance is not defined #399

Open arqex opened 2 months ago

arqex commented 2 months ago

First thanks for this marvelous library. I've been using it for years and work great.

Second, the last version 16.13.1 is breaking my node server.

This is what I getting in the server console

ReferenceError: performance is not defined
    at new OnClickOutside(ClickOut) (webpack-internal:///../../node_modules/react-onclickoutside/dist/react-onclickoutside.cjs.js:262:29)

I could use react-onclickoutside to render my application in the server side without any problems, but performance is not defined by default in node environments, it has to be imported.

An alternative for performance.now() would be Date.now(), that is available everywhere, but maybe it doesn't have the precision needed.

Another alternative is make react-onclickoutside transparent when rendered in the server, just return the component it wraps, as in the server is not possible to make clicks.

Pomax commented 2 months ago

Sounds like you're on a dead version of Node: which version are you using? performance has been in Node since v16, which is already old enough to have reached EOL.