Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with SSR? #90

Closed
rfoel opened this issue Jan 6, 2019 · 7 comments
Closed

Issue with SSR? #90

rfoel opened this issue Jan 6, 2019 · 7 comments
Labels

Comments

@rfoel
Copy link

rfoel commented Jan 6, 2019

I tried to use the package on next.js and it throws the following error:

Error: Addon "cssom" is missing the following dependencies:
 require("nano-css/addon/sh").addon(nano);
    at warnOnMissingDependencies (/Users/rafael/Code/blumpa-ssr/node_modules/nano-css/addon/__dev__/warnOnMissingDependencies.js:23:15)
    at exports.addon (/Users/rafael/Code/blumpa-ssr/node_modules/nano-css/addon/cssom.js:5:55)
    at Object.<anonymous> (/Users/rafael/Code/blumpa-ssr/node_modules/react-use/lib/useCss.js:27:1)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/rafael/Code/blumpa-ssr/node_modules/react-use/lib/index.js:17:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
@streamich
Copy link
Owner

Looks like nano-css cssom addon does not support server side rendering. Either that addon has to detect SSR or in this lib we need to detect SSR and apply CSS differently. I guess, it's better if nano-css supports it.

@Jivings
Copy link
Contributor

Jivings commented Jan 13, 2019

I'm getting this error trying to build normally. Is there a workaround?

@streamich
Copy link
Owner

streamich commented Jan 13, 2019

Do you still get that error if you include a specific hook?

import myHook from 'react-use/lib/myHook';

@nestarz
Copy link

nestarz commented Jan 24, 2019

same here using

import { useWindowSize } from "react-use";

@tom2strobl
Copy link

Do you still get that error if you include a specific hook?

import myHook from 'react-use/lib/myHook';

Just for others like me now coming to the thread – importing a specific hook like mentioned indeed solves the issue. I was using next as well.

@unix
Copy link

unix commented Mar 26, 2019

Do you still get that error if you include a specific hook?

import myHook from 'react-use/lib/myHook';

resolved. issue from useCss.ts > import {create, NanoRenderer} from 'nano-css'.
would you consider refactoring here?

streamich pushed a commit that referenced this issue Mar 26, 2019
# [6.0.0](v5.16.1...v6.0.0) (2019-03-26)

### Bug Fixes

* 🐛 bump nano-css ([f1f36dc](f1f36dc)), closes [#90](#90)
* 🐛 don't throw only in development ([f5faba5](f5faba5))

### chore

* 🤖 don't install only large dependencies ([6170067](6170067))

### Features

* 🎸 add {bound} option to useMouse ([9bb02a1](9bb02a1))
* 🎸 implement useClickAway, remove useOutsideClick ([a03143a](a03143a))
* 🎸 keep global state of all useLockBodyScroll hooks ([5dd10e9](5dd10e9))
* 🎸 move extra mouse functionality into useMouseHovered ([8b0580e](8b0580e))
* more precise size for useMouse ([b887075](b887075))

### BREAKING CHANGES

* 🧨 error is logged instead of thrown in development environment
* 🧨 useOutsideClick is now useClickAway
* 🧨 useCallbag hook is removed, some hooks KeyboardJS and Rebound installed
separately
@streamich
Copy link
Owner

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants