-
Notifications
You must be signed in to change notification settings - Fork 144
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
useStyles enhancement #198
base: main
Are you sure you want to change the base?
Conversation
@dazlious hello there! Any progress on this PR?
I would really appreciate if you could merge this PR since it fixes issue described above |
import StyleContext from './StyleContext' | ||
|
||
// To detect if it's in SSR process or in browser. Wrapping with | ||
// the function makes rollup's replacement of "this" avoidable | ||
// eslint-disable-next-line func-names | ||
const isBrowser = (() => this && typeof this.window === 'object')() | ||
const isBrowser = (() => typeof window === 'object')() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a more typical way of checking would be:
typeof window !== 'undefined'
@@ -25,7 +25,7 @@ function useStyles(...styles) { | |||
} | |||
} | |||
if (isBrowser) { | |||
useEffect(runEffect, []) | |||
useLayoutEffect(runEffect, styles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are you trying to solve here?
I know this repo does not have any tests, but we should start adding them in. Would be nice if you can provide some for your special usecase
Still waiting for a reply here: #198 (comment) |
No description provided.