@omer_bhatti/react-keys

1.0.1 • Public • Published

Installation

npm i @omer_bhatti/react-keys

Usage

import KeyGenerator from '@omer_bhatti/react-keys'
import React from 'react'

export default function index() {
    const data = ["item1", "item2", "item3", "item4", "item5"];
    return (
        <div>
        {
            data.map((item) => (
                <div key={KeyGenerator.getKey()}>
                    {item}
                </div>
            ))
        }
        <div/>
    )
}

Functions

increment()      - Increments the key
getKey()         - Returns the current key and increment the key
getHashKey()     - Returns the key as Hashed String and increment the key
setkey(value)    - sets the key to new value
reset()          - resets the key to 0
getNextKey()     - returns the next key
getPreviousKey() - returns the previous key

Bugs

if you face any issue like SyntaxError: Cannot use import statement outside a module just add this to your packages.json file

{
    "type": "module"
}

Package Sidebar

Install

npm i @omer_bhatti/react-keys

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.23 kB

Total Files

3

Last publish

Collaborators

  • omer_bhatti