https://github.com/dzucconi/use-cursor
A React hook to cycle an index within some max length
https://github.com/dzucconi/use-cursor
cursor react react-hook typescript
Last synced: about 2 months ago
JSON representation
A React hook to cycle an index within some max length
- Host: GitHub
- URL: https://github.com/dzucconi/use-cursor
- Owner: dzucconi
- License: mit
- Created: 2020-03-24T14:28:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T20:22:01.000Z (almost 2 years ago)
- Last Synced: 2025-06-22T19:54:48.692Z (4 months ago)
- Topics: cursor, react, react-hook, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/use-cursor
- Size: 1.63 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-cursor
[](https://github.com/semantic-release/semantic-release) [](https://www.npmjs.com/package/use-cursor) [](https://travis-ci.org/dzucconi/use-cursor)
## What is this?
A React hook to cycle an index within some max length
## Installation
```bash
yarn add use-cursor
```## Usage
```javascript
import React from "react";
import { useCursor } from "use-cursor";const App: React.FC = () => {
const { index, cursor, handlePrev, handleNext } = useCursor({ max: 10 });return (
Next
Previous
{JSON.stringify({ index, cursor })}
);
};
```## Interface
```typescript
const useCursor: ({
max,
initialCursor
}: {
max: number;
initialCursor?: number | undefined;
}) => {
handlePrev: () => void;
handleNext: () => void;
cursor: number;
index: number;
};
```