1.1.6 • Published 2 years ago

use-callback-creator v1.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

use-callback-creator

A hook to add a lot of similar callbacks inside a React component

NPM JavaScript Style Guide

Install

npm install --save use-callback-creator

Usage

import React, { useState } from 'react'
import useCallbackCreator from 'use-callback-creator'

const Example = () => {

  const [counters, setCounter]=useState([0,0,0,0]);

  const handleAdd = useCallbackCreator((index)=>{
        const newCounters=[...counters];
        newCounters[index]+=1;
        setCounters(counters);
    },[counters]);

  return (
    <div>
        {counters.map( (count, index)=>
            <div>{count} <button onClick={handleAdd(index)}>Add</button>
        )}
    </div>
  )
}

License

MIT © MarkEhr


This hook is created using create-react-hook.

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago