🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-node-key

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-node-key

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

0.4.0
latest
Source
npm
Version published
Weekly downloads
5.8K
-31.99%
Maintainers
1
Weekly downloads
 
Created
Source

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')
)

Keywords

node key

FAQs

Package last updated on 20 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts