'How to resolve Uncaught RangeError based on uuid function

I'm creating a React JS project in which I'm using uuid from uuidv4 to generate and use a new uuid per object I'm creating. I'm testing it now and getting the following error:

Uncaught RangeError: Maximum call stack size exceeded
    at Object.exports.deprecate (util.js:75:1)

The error is popping up when this method is called. I think it has to do with my use of uuid. Without that line, the app is running without the error.

  const addContactHandler = (contact) => {
    console.log(contact)
    setContacts([...contacts, {id: uuid(), contact}])
  };

If anyone has any ideas how I can fix this, any advice would be much appreciated!



Solution 1:[1]

I was able to resolve this by using the package react-uuid instead of uuidv4. Otherwise, no code changes were required.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ENV