uuid react
npm i react-uuid
import React from 'react'
import uuid from 'react-uuid'
const array = ['one', 'two', 'three']
export const LineItem = item => <li key={uuid()}>{item}</li>
export const List = () => array.map(item => <LineItem item={item} />)
function uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var userID=uuid();//something like: "ec0c22fa-f909-48da-92cb-db17ecdb91c5"
Also in JavaScript:
- how to execute javascript after c# function execute
- how to floor a number in javascript
- how to check if function is running js
- access angular app outside localhost
- rest parameter javascript
- make angular to run on a different port
- jquery remove class
- do more than one thing at start of or loop javascript
- random in a range js
- express get request origin
- json array on jasper
- how to use session using javascript
- calculate log in javascript
- js index to index
- how to create a variable javascript
- package json proxy
- Javascript merge two objects
- map object array javascript
- javascript sort numbers descending
- react 17
- testing a function in jest on click react
- javascript get base url
- react routes
- document.queryselector picks first or last