Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0x1luxa/hooks
A collection of hooks for React
A collection of hooks for React, designed to simplify state management and interaction with web3.
To install the package, use npm or yarn:
npm install @0x1luxa/hooks
or
yarn add @0x1luxa/hooks
A hook to copy text to the clipboard.
Example:
import { useClipboard } from "@0x1luxa/hooks"
const Component = () => {
const [copy] = useClipboard()
return (
<button onClick={() => copy("Text to copy")}>
Copy to Clipboard
</button>
)
}
A hook to determine the device width and breakpoints.
Example:
import { useDeviceWidth } from "@0x1luxa/hooks"
const Component = () => {
const { isBelowDesktop, isTablet, isMobile } = useDeviceWidth()
return (
<div>
{isMobile && <p>Mobile View</p>}
{isTablet && <p>Tablet View</p>}
{isBelowDesktop && <p>Below Desktop View</p>}
</div>
)
}
A hook to get the dimensions of a DOM element.
Example:
import { useDimensions } from "@0x1luxa/hooks"
import { useRef } from "react"
const Component = () => {
const ref = useRef<HTMLDivElement>(null)
const dimensions = useDimensions(ref)
return (
<div ref={ref}>
Width: {dimensions.width}, Height: {dimensions.height}
</div>
)
}
A hook to manage the open/close state of a component.
Example:
import { useDisclosure } from "@0x1luxa/hooks"
const Component = () => {
const [isOpen, { open, close, toggle }] = useDisclosure()
return (
<div>
<button onClick={toggle}>Toggle</button>
{isOpen && <p>Content is open</p>}
</div>
)
}
A hook to manage state with local storage.
Example:
import { useLocalStorage } from "@0x1luxa/hooks"
const Component = () => {
const [value, setValue] = useLocalStorage("key", "default")
return (
<div>
<input
value={value}
onChange={(e) => setValue(e.target.value)}
/>
</div>
)
}
A hook to handle pagination logic.
Example:
import { usePagination } from "@0x1luxa/hooks"
const Component = () => {
const { currentPage, totalPages, setPage } = usePagination(10, 100)
return (
<div>
<button onClick={() => setPage(currentPage - 1)}>
Previous
</button>
<span>
Page {currentPage} of {totalPages}
</span>
<button onClick={() => setPage(currentPage + 1)}>Next</button>
</div>
)
}
A hook to toggle a boolean state every 1.5 seconds when data is available.
Example:
import { useToggleEvery1_5Sec } from "@0x1luxa/hooks"
const Component = ({ data }) => {
const [toggle, resetToggle] = useToggleEvery1_5Sec(data)
return (
<div>
<p>Toggle is {toggle ? "ON" : "OFF"}</p>
<button onClick={resetToggle}>Reset</button>
</div>
)
}
A hook to handle token approval transactions.
Example:
import { useApproveToken } from "@0x1luxa/hooks"
const Component = () => {
const { approve, isLoading } = useApproveToken({
tokenAddress: "0xTokenAddress",
spenderAddress: "0xSpenderAddress",
amount: BigInt(1000),
})
return (
<button onClick={approve} disabled={isLoading}>
Approve Token
</button>
)
}
A hook to get the balance of a token.
Example:
import { useTokenBalance } from "@0x1luxa/hooks"
const Component = () => {
const balance = useTokenBalance("0xTokenAddress")
return <div>Token Balance: {balance}</div>
}
To build the project, run:
npm run build
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
0x1luxa
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
tsupEnvironment{
"local_name": "tsup",
"alias": false,
"peer_metadata": null
} | ^8.4.0 | runtime |
viemEnvironment{
"local_name": "viem",
"alias": false,
"peer_metadata": null
} | ^2.23.12 | runtime |
dayjsEnvironment{
"local_name": "dayjs",
"alias": false,
"peer_metadata": null
} | ^1.11.13 | runtime |
reactEnvironment{
"local_name": "react",
"alias": false,
"peer_metadata": null
} | ^19.0.0 | runtime |
wagmiEnvironment{
"local_name": "wagmi",
"alias": false,
"peer_metadata": null
} | ^2.14.15 | runtime |
bignumber.jsEnvironment{
"local_name": "bignumber.js",
"alias": false,
"peer_metadata": null
} | ^9.1.2 | runtime |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^22 | development |
@types/reactEnvironment{
"local_name": "@types/react",
"alias": false,
"peer_metadata": null
} | ^19.0.11 | development |
Source distribution
{
"shasum": "f952f40b401b26bf8fa276dbacecd15dea4767ee",
"tarball": "https://registry.npmjs.org/@0x1luxa/hooks/-/hooks-0.1.8.tgz",
"fileCount": 4,
"integrity": "sha512-CORL8ilIHlOO/6etqb7u4KzOLqvcK2SiWL1r7eXUvR5lDD3cG6ekYQ3EUhc6b8Ez9Zbe9FwdykGrgHq4uc4CgQ==",
"signatures": [
{
"sig": "MEYCIQCdeZbTm7MZRxPnDgOJnbYH7JZL38sBqur0i1cvlkBXhAIhAPXMxlKTWiTNcB0Hso3QYW9ZIkobnwXIR4iU3Vgt7DTY",
"keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
}
],
"unpackedSize": 57872
}Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:a657507ebd1e9c306ccd19f03e294a9848272a67d13ff70a714e1633d899dceb