infinesse
infinesse

Reputation: 107

Crash in react-native-Uuid-generator when using library in expo app

I want to generate a uuid in ReactNative app built with expo cli.. when I install UUIDGenerator from React-native-uuid-generator, I get undefined is not an object(evaluating ‘RNUUIDGenerator.getRandomUUID’..)

Tried two dif libraries, react-native-uuid, and React-native-uuid-generator, same problem, think it might have to do with expo not liking the link command.

UUIDGenerator.getRandomUUID().then(uuid => console.log(uuid));

Expecting new uuid to be printed, actually getting error message.

Upvotes: 2

Views: 6168

Answers (1)

Junius L
Junius L

Reputation: 16132

react-native-uuid works with expo.

npm install react-native-uuid --save

import uuid from 'react-native-uuid';

then generatte uuid like

const uuid = uuid.v1();

Upvotes: 8

Related Questions