Git Product home page Git Product logo

use-cursor's Introduction

use-cursor

semantic-release npm Build Status

What is this?

A React hook to cycle an index within some max length

Installation

yarn add use-cursor

Usage

import React from "react";
import { useCursor } from "use-cursor";

const App: React.FC = () => {
  const { index, cursor, handlePrev, handleNext } = useCursor({ max: 10 });

  return (
    <button onClick={handleNext}>Next</button>
    <button onClick={handlePrev}>Previous</button>
    <pre>
      <code>{JSON.stringify({ index, cursor })}</code>
    </pre>
  );
};

Interface

const useCursor: ({
  max,
  initialCursor
}: {
  max: number;
  initialCursor?: number | undefined;
}) => {
  handlePrev: () => void;
  handleNext: () => void;
  cursor: number;
  index: number;
};

use-cursor's People

Contributors

renovate-bot avatar dzucconi avatar renovate[bot] avatar

Stargazers

Jason Mandel avatar Andrew Chou avatar

Watchers

 avatar  avatar

use-cursor's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • map-cursor-to-max ^1.0.0
  • @testing-library/react 10.4.9
  • @testing-library/react-hooks 3.7.0
  • @types/jest 25.2.3
  • @types/react 16.14.28
  • cz-conventional-changelog 3.3.0
  • jest 25.5.4
  • react 16.14.0
  • react-dom 16.14.0
  • react-test-renderer 16.14.0
  • semantic-release 17.4.7
  • ts-jest 25.5.1
  • typescript 3.9.10
  • react >=16.8.0
  • react-dom >=16.8.0
travis
.travis.yml
  • node 8
  • node lts/*

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.