rafgraph / react-interactive

Better hover, active and focus states than CSS pseudo-classes, and a callback when the interactive state changes.
https://react-interactive.rafgraph.dev
MIT License
167 stars 8 forks source link

document is not defined #18

Closed damianryann closed 3 years ago

damianryann commented 3 years ago

Hi there, I have a simple error appearing when my webpack ssr app is trying to compile.

The application I am working on is an older version of node v8.9.4 and React v15.3.2 incase this is a versioning issue.

/node_modules/react-interactive/lib/notifier.js:121 setupEvent(document, eType, eType === 'mouseenter' ? handleNotifyAllAndNext : handleNotifyAll

Any idea how I can circumvent this issue? I have tried wrapping in a client component, but no dice.

damianryann commented 3 years ago

Just realised this supports react >=16.3 which is where I am likely having my issue.

rafgraph commented 3 years ago

v0.8.1 supports react v15, you can try installing that version https://github.com/rafgraph/react-interactive/tree/v0.8.1

This doesn’t support ssr as it needs access to the document to set event listeners.

I’m working on a re-write that should be released in a couple of weeks. It will support ssr, but uses hooks so it needs react v16.8.

rafgraph commented 3 years ago

Also, not sure what features of react interactive you needed to use, but you may find Event From helpful. It contains some of the core functionality for React Interactive and supports ssr (I pulled it out into its own package for the re-write). https://github.com/rafgraph/event-from