Skip to content

Commit

Permalink
docs: link to React Native readme section from rng error
Browse files Browse the repository at this point in the history
For linkability, move react-native docs to separate section.
  • Loading branch information
ctavan committed Feb 27, 2020
1 parent 719e1b4 commit 3282056
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
- Node 8, 10, 12
- Chrome, Safari, Firefox, Edge, IE 11 browsers
- Webpack and rollup.js module bundlers
- [React Native](#react-native)
- **Secure** - Cryptographically-strong random values
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
- **CLI** - Includes the [`uuid` command line](#command-line) utility
Expand All @@ -35,8 +36,6 @@ versions, all of which are supported here. In order of popularity, they are:

**Unsure which one to use?** Use version 4 (random) unless you have a specific need for one of the other versions. See also [this FAQ](https://github.com/tc39/proposal-uuid#faq).

**Are you using React Native?** If you are using this library from React Native, you need to add a polyfill for `crypto.getRandomValues`. We recommend using [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

### Create Version 4 (Random) UUIDs

```javascript
Expand Down Expand Up @@ -336,6 +335,12 @@ Available bundles:
- https://unpkg.com/uuid@latest/dist/umd/
- https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/

## React Native

If you are using this library from React Native, you need to add a polyfill for
`crypto.getRandomValues()`. We recommend using
[`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
9 changes: 7 additions & 2 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
- Node 8, 10, 12
- Chrome, Safari, Firefox, Edge, IE 11 browsers
- Webpack and rollup.js module bundlers
- [React Native](#react-native)
- **Secure** - Cryptographically-strong random values
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
- **CLI** - Includes the [`uuid` command line](#command-line) utility
Expand All @@ -48,8 +49,6 @@ versions, all of which are supported here. In order of popularity, they are:

**Unsure which one to use?** Use version 4 (random) unless you have a specific need for one of the other versions. See also [this FAQ](https://github.com/tc39/proposal-uuid#faq).

**Are you using React Native?** If you are using this library from React Native, you need to add a polyfill for `crypto.getRandomValues`. We recommend using [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

### Create Version 4 (Random) UUIDs

```javascript --run v4
Expand Down Expand Up @@ -325,6 +324,12 @@ Available bundles:
- https://unpkg.com/uuid@latest/dist/umd/
- https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/

## React Native

If you are using this library from React Native, you need to add a polyfill for
`crypto.getRandomValues()`. We recommend using
[`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme).

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
2 changes: 1 addition & 1 deletion src/rng-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
export default function rng() {
if (!getRandomValues) {
throw new Error(
'uuid: This browser does not seem to support crypto.getRandomValues(). If you need to support this browser, please provide a custom random number generator through options.rng.',
'uuid: This environment does not seem to support crypto.getRandomValues(). Install a polyfill or provide a custom random number generator through options.rng. For React Native, see https://github.com/uuidjs/uuid#react-native',
);
}
return getRandomValues(rnds8);
Expand Down

0 comments on commit 3282056

Please sign in to comment.