-
Notifications
You must be signed in to change notification settings - Fork 2
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
First draft useScreenOrientation #325
base: main
Are you sure you want to change the base?
First draft useScreenOrientation #325
Conversation
defaultValue = false, | ||
): boolean { | ||
defaultValue?: boolean, | ||
): boolean | undefined { |
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.
in what scenario would you want undefined
to be returned ?
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.
This could be helpful for SSR, and only on client side return a boolean 🤔
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.
Interesting. I wonder what you would do with this then... not render something at all?
You always get a hydration error then? And this value on the client should only be used after the first render?
isLandscape: boolean | undefined; | ||
isPortrait: boolean | undefined; |
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.
These are mutually exclusive, so why not return 'landscape' | 'portrait'
?
I don't know if it's helpful to add this as a hook because the only thing it does is provide a default value for the That'll mean that you can get the same behaviour with something like this: import { useMediaQuery, landscapeOrientationMediaQuery } from '@mediamonks/react-kit`
const isLandscape = useMediaQuery(landscapeOrientationMediaQuery) instead of import { useScreenOrientation } from '@mediamonks/react-kit`
const isLandscape = useScreenOrientation() Additionally, browsers have a not super well supported |
No description provided.