Skip to content

docs: add information on usage from React Native#385

Merged
ctavan merged 1 commit intouuidjs:masterfrom
LinusU:react-native
Feb 27, 2020
Merged

docs: add information on usage from React Native#385
ctavan merged 1 commit intouuidjs:masterfrom
LinusU:react-native

Conversation

@LinusU
Copy link
Copy Markdown
Member

@LinusU LinusU commented Feb 26, 2020

Closes #375

This adds information on how to get the library working on React Native to the readme.


I've verified that this works by:

  1. creating a new React Native project (npx react-native init uuidtest)
  2. added the dependencies (npm add react-native-get-random-values uuid)
  3. imported the polyfill (import 'react-native-get-random-values' in index.js)
  4. and displayed an UUID in the app (import * as uuid from 'uuid' and {uuid.v4()} in App.js)

@LinusU
Copy link
Copy Markdown
Member Author

LinusU commented Feb 26, 2020

ping @ctavan, this PR is per my comments in #375 ☺️

@ctavan ctavan merged commit 719e1b4 into uuidjs:master Feb 27, 2020
@LinusU LinusU deleted the react-native branch February 27, 2020 12:25
@SimenB
Copy link
Copy Markdown
Contributor

SimenB commented Feb 27, 2020

Does this work in Expo? If not (seems like it's a native lib), a separate section for expo would be ❤️

@geraintwhite
Copy link
Copy Markdown

After including that polyfill the errors change to the following on both iOS and Android:

'Unhandled promise rejection', { [TypeError: null is not an object (evaluating 'RNGetRandomValues.getRandomBase64')]

@LinusU
Copy link
Copy Markdown
Member Author

LinusU commented Feb 27, 2020

@SimenB ah right, no it won't. Expo currently doesn't have a sync random api, opening upstream issue now

@grit96 is that on Expo?

@geraintwhite
Copy link
Copy Markdown

@LinusU nope, RN 0.59. I just realised that react-native-get-random-values probably needs linking because I'm using RN < 0.60.

@LinusU
Copy link
Copy Markdown
Member Author

LinusU commented Feb 27, 2020

probably needs linking because I'm using RN < 0.60

Yeah, that's probably it.

Sorry, I removed the linking step from the readme since I thought that most people would be on >= 0.60 by now ☺️

@LinusU
Copy link
Copy Markdown
Member Author

LinusU commented Feb 27, 2020

Issue filed with Expo here: expo/expo#7209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Version >=7.0.0 is not compatible with React Native / Expo

4 participants