React Native - why does uuid return "TypeError: undefined is not a function, js engine: hermes"?

134 Views Asked by At

I am working on a React Native project where I need to generate unique keys, so uuid was a good choice. But after a couple of tries, I receive the error message "TypeError: undefined is not a function, js engine: hermes".

import { v4 as uuidv4 } from 'uuid';
[...]
let der_schluessel;
try {
  der_schluessel = uuidv4();
} catch(e) {
  console.log(e);
  console.log("Sadly, a uuid couldn't be generated.")
  der_schluessel = Math.random() * 3000;
}
[...]

I have tried clearing the cache, but it didn't work. It's odd as I received the same error message yesterday, though today when I started the application the function performed perfectly in the first tries and only failed in the third. Where is the problem?

0

There are 0 best solutions below