
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@custom-react-hooks/use-orientation
Advanced tools
The `useOrientation` hook is designed for both React web and mobile applications, providing a comprehensive solution to monitor and respond to orientation changes. This hook can track the orientation of the device or a specific HTML element, offering valu
The useOrientation hook is designed for both React web and mobile applications, providing a comprehensive solution to monitor and respond to orientation changes. This hook can track the orientation of the device or a specific HTML element, offering valuable data for responsive and dynamic UIs.
window object, making it suitable for server-side rendering.npm install @custom-react-hooks/use-orientation
or
yarn add @custom-react-hooks/use-orientation
npm install @custom-react-hooks/all
or
yarn add @custom-react-hooks/all
The useOrientation hook must be imported using a named import as shown below:
Named Import:
import { useOrientation } from '@custom-react-hooks/use-orientation';
This approach ensures that the hook integrates seamlessly into your project, maintaining consistency and predictability in how you use our package.
import React, { useRef } from 'react';
import { useOrientation } from '@custom-react-hooks/all';
const OrientationComponent = () => {
const elementRef1 = useRef(null);
const elementRef2 = useRef(null);
const elementOrientation1 = useOrientation(elementRef1, false);
const elementOrientation2 = useOrientation(elementRef2, false);
const windowOrientation = useOrientation(undefined, true);
return (
<div>
<div ref={elementRef1}>
<strong>Element 1: </strong> {elementOrientation1.elementOrientation}
<br />
<strong>Aspect Ratio:</strong>
{elementOrientation1.aspectRatio ? elementOrientation1.aspectRatio.toFixed(2) : 0}
</div>
<div ref={elementRef2}>
<strong>Element 2: </strong>
{elementOrientation2.elementOrientation}
<br />
<strong>Aspect Ratio:</strong>
{elementOrientation2.aspectRatio ? elementOrientation2.aspectRatio.toFixed(2) : 0}
</div>
<p>Window Orientation: {windowOrientation.type}</p>
</div>
);
};
export default OrientationComponent;
In this example, the useOrientation hook is used to monitor the orientation of both the device's window and a specific image element.
elementRef (Optional): A React RefObject to an HTML element.trackWindow (Optional): Boolean to track the device's window orientation.angle: The current orientation angle of the device or element in degrees.type: The orientation type ('landscape-primary', 'landscape-secondary', 'portrait-primary', 'portrait-secondary').aspectRatio: The aspect ratio of the referenced element (if provided).elementOrientation: The orientation of the referenced element ('landscape' or 'portrait').We welcome contributions to improve useOrientation. Feel free to submit issues or pull requests to the repository for enhancements, bug fixes, or documentation improvements.
FAQs
The `useOrientation` hook is designed for both React web and mobile applications, providing a comprehensive solution to monitor and respond to orientation changes. This hook can track the orientation of the device or a specific HTML element, offering valu
The npm package @custom-react-hooks/use-orientation receives a total of 717 weekly downloads. As such, @custom-react-hooks/use-orientation popularity was classified as not popular.
We found that @custom-react-hooks/use-orientation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.