Giter Site home page Giter Site logo

react-native-uuid's Introduction

react-native-uuid

GitHub license npm npm downloads total npm downloads GitHub watchers GitHub stars GitHub forks open bugs total open issues GitHub pull requests

Packagephobia Bundlephobia

react-native-uuid is a zero-dependency TypeScript implementation of RFC4122 standard A Universally Unique IDentifier (UUID) URN Namespace. Please note, this library uses pseudo random generator based on top of Math.random. New version with hardware support is WIP.

Heavily inspired by:

Huge thanks to Randy Coulman for the early version of a code.

Getting started

Use this steps to install and create UUIDs. Example project is available here

1. Install

npm install react-native-uuid

2. Create a UUID

import uuid from 'react-native-uuid';
uuid.v4(); // ⇨ '11edc52b-2918-4d71-9058-f7285e29d894'

Documentation

Methods documentation is available here

Troubleshooting

Previous version has been based on randombytes that is not compatible with react-native out of the box. Please submit an issue if you found a bug.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Sponsorship

Thank you to our sponsors:

Reactive Lions™

License

MIT

Copyright (c) 2016-2024 Eugene Hauptmann

react-native-uuid's People

Contributors

danielramosacosta avatar dependabot[bot] avatar eufelipe avatar eugenehp avatar harikrishnanp avatar qburst-harikrishnanp avatar reactivelions avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-uuid's Issues

Why would you ever want a UUID in the form of a number array?

In the latest release: version 2.0.0, the type signature of the return parameter in the v4 UUID function changed from string to string | number[]. Why? I'm curious what use case would require the UUID to be represented as a number array? As the change in the return signature is breaking for typescript projects that depend on the typed return signature. (which could be interpreted from the major release bump)

Doesn't work?

error: bundling failed: "Unable to resolve module buffer from D:\\ProjectABC\\node_modules\\safe-buffer\\index.js: Module does not exist in the module map\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache."

Used it like the example using require, and even tried import - same result.
Also installing the module 'buffer' seperately doesnt help anything. I guess it's deprecated?

Wrong uuid v5 when using namespaces

Using v5 in the internet:
image

Using v5 with this library:

import uuid from 'react-native-uuid';

//Not a real component - just a concept
const DummyComponent = () => {
  console.log({
    actualId: uuid.v5("orderId","f87ff660-ef24-47a6-b9a8-d64545dd6a4e"),
    expectedId: "02cd8985-1b72-5e1f-a597-392fc492ca68",
  });
}

Result is:

{
    "actualId": "31306430-6633-5136-b061-636236373634",
    "expectedId": "02cd8985-1b72-5e1f-a597-392fc492ca68"
}

I have look inside the V5 code and its look like you changing the variables for some reason. Any reason why?

[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()

I am getting following warning:

[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()
- node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn
- node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn
- node_modules\moment\moment.js:4595:17 in <anonymous>
- node_modules\react-native-uuid\uuid.js:25:8 in setupBrowser
- node_modules\react-native-uuid\uuid.js:220:6 in v4
- node_modules\metro\src\lib\polyfills\require.js:322:6 in loadModuleImplementation
* assets\images\logo.png:1:117 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:322:6 in loadModuleImplementation
* http://192.168.0.36:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:123550:52 in <unknown>
- node_modules\metro\src\lib\polyfills\require.js:322:6 in loadModuleImplementation
- node_modules\expo\AppEntry.js:5:0 in <global>
- node_modules\metro\src\lib\polyfills\require.js:322:6 in loadModuleImplementation
- node_modules\metro\src\lib\polyfills\require.js:201:45 in guardedLoadModule
* src\app\setting\settings.js:10:5 in Settings

I am using expo SDK 36. Below is my package.json

"dependencies": {
    "@expo/vector-icons": "^10.0.6",
    "@react-native-community/datetimepicker": "^2.1.0",
    "@react-native-community/masked-view": "^0.1.6",
    "buffer": "^5.4.3",
    "expo": "~36.0.0",
    "expo-barcode-scanner": "^8.0.0",
    "expo-font": "^8.0.0",
    "expo-secure-store": "^8.0.0",
    "moment": "^2.24.0",
    "native-base": "^2.13.8",
    "react": "^16.12.0",
    "react-dom": "~16.9.0",
    "react-native": "~0.61.4",
    "react-native-gesture-handler": "^1.5.3",
    "react-native-multiple-select": "^0.5.5",
    "react-native-reanimated": "~1.4.0",
    "react-native-safe-area-context": "^0.6.2",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-svg": "9.3.0",
    "react-native-unimodules": "~0.7.0",
    "react-native-uuid": "^1.4.9",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^2.0.15",
    "react-navigation-tabs": "^2.7.0",
    "sentry-expo": "^2.0.1",
    "victory-native": "^33.0.0"
  },

randomBytes cannot find module buffer

Thanks for the great library. I had encounter a strange problem that may not happen on other developers.

After I delete node_module folder and reinstall by npm install, the react-native packager stop working and it reports randomBytes cannot find module buffer. I check the dependency tree and found it is caused by react-native-uuid. I had fixed this by manually install buffer by npm install buffer --save-dev but it is not ideal.
Please advise if you have better solution.

Thanks in advance.

JSON5: invalid character 'm' at 1:1

In my case this error occurs while calling the module.

Apparently it's because of the babel.config.json file that has the wrong extension, it should be babel.config.js

Changing this no longer gives me this error.

Node v16
React Native v0.68
React Native uuid v2.0.1
Windows 11

_rng is not a function

This works fine when I run in simulator/etc.

But when I try to get my unit tests to pass (mocha/istanbul), I get the following error:

/Users/g/stardust-app/node_modules/react-native-uuid/uuid.js:121
var _seedBytes = _rng();
^
TypeError: _rng is not a function

Default import no longer works

Hi,

Nice job on the 2.0.0 release!

However it seems to have broken usage of the default exports.

import { v4 } from 'react-native-uuid';
This works.

import * as uuid from 'react-native-uuid';
This works but Typescript suggests converting it to a default import, which then doesn't work.

import uuid from 'react-native-uuid';
This no longer works, and is how we were previously importing. I do see the docs mention using import * but this is still a breaking change from the previous version.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.