uuid npm typescript code example
Example 1: uuid react
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} />)
Example 2: uuid react
npm i react-uuid
Example 3: create uuid typescript
import { v4 as uuid } from 'uuid';
const uuid = require('uuid/v4');
const myUUID = uuid();
const uuid = () =>
"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);
});
const myUUID = uuid();