Minimal library to create Guids in React Native. It uses the native implementations to generate one and send it over to JS.
When faced with the problem of generating a GUID in React Native, I found that there were no current good solutions. Relying on
Math.random didn't seem like a good idea, and the other alternatives found like react-native-uuid that are just ports of node.js libraries (needed to install other libraries buffer).
Since native platforms already have ways to create GUIDs that are useful, creating a simple native library would be enough to use them in React-Native.
$ npm install react-native-create-guid --save
Mostly automatic installation
RN < 0.60:
$ react-native link react-native-create-guid
RN >= 0.60:
$ cd ios && pod install
- In XCode, in the project navigator, right click
Add Files to [your project's name]
- Go to
- In XCode, in the project navigator, select your project. Add
libCreateGuid.ato your project's
Link Binary With Libraries
- Run your project (
- Open up
import com.reactnative.createguid.CreateGuidPackage;to the imports at the top of the file
new CreateGuidPackage()to the list returned by the
- Append the following lines to
include ':react-native-create-guid' project(':react-native-create-guid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-create-guid/android')
- Insert the following lines inside the dependencies block in
Check the example under
example folder for it's usage.
;// in an async function;const guid = await ;// using promises;