bradtraversy / react_crash_todo

React crash course files
372 stars 322 forks source link

import uuid from 'uuid'; not working! #14

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello! Importing is not working for uuid. It says :

Failed to compile. ./src/App.js Attempted import error: 'uuid' does not contain a default export (imported as 'uuid').

But this is working : const uuid = require('uuid');

Why it is showing error?

adisen commented 4 years ago

As the error says, there is not default export with that name. This is the way to use it:

import { v4 as uuidv4 } from 'uuid';

Check https://www.npmjs.com/package/uuid

ghost commented 4 years ago

Oh yes! Now its working! Thanks!

adisen commented 4 years ago

You can close the issue now...