react-node-key
Automatic key-marked for React nodes, generate an unique identifier by render location
Last updated 6 years ago by cjy0208 .
ISC · Repository · Original npm · Tarball · package.json
$ npm install react-node-key 
SYNC missed versions from official npm registry.

React Node Key

size dm

English | 中文说明

Automatic key-marked for React nodes, generate an unique identifier by render location


Compatibility

  • React v16+

  • Preact v10+


Install

yarn add react-node-key
# or
npm install react-node-key

Usage

1. Add react-node-key/babel plugins in .babelrc

Why is it needed?

The plugin adds a _nk attribute to each JSX element during compilation to help the react-node-key runtime generate an unique identifier by render location.

{
  "plugins": [
    "react-node-key/babel"
  ]
}

2. Use <NodeKey> as your component's wrapper

import React from 'react'
import ReactDOM from 'react-dom'
import NodeKey from 'react-node-key'

import Test from './Test'

ReactDOM.render(
  <NodeKey>{nodeKey => <Test key={nodeKey} />}</NodeKey>,
  document.getElementById('root')
)

Current Tags

  • 0.4.0                                ...           latest (5 years ago)

17 Versions

  • 0.4.0                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.8                                ...           6 years ago
  • 0.1.7                                ...           6 years ago
  • 0.1.6                                ...           6 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Total 56
Today 0
This Week 1
This Month 21
Last Day 0
Last Week 2
Last Month 19
Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE