1.0.1 • Published 2 years ago

@omer_bhatti/react-keys v1.0.1

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

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"
}