React / 'uuid' does not contain a default export (imported as 'uuid')

uuid 사용시 문제

공식문서는 https://www.npmjs.com/package/uuid에서 확인가능하다.

import uuid from "uuid"를 아래의 코드로 바꾸면 된다.

import {v1 as uuid} from "uuid"; 
// import {v3 as uuid} from "uuid"; 
// import {v4 as uuid} from "uuid"; 
// import {v5 as uuid} from "uuid"; 


class App extends React.Component{
  state = {
    todos:[
      {
        id: uuid(),
        title: 'Take out the trash',
        completed: false
      }
    ]
  }
  
  addTodo = (title) => {
    const newTodo = {
      id: uuid(),
      title,
      completed: false
    }
    this.setState({ todos: [...this.state.todos, newTodo] })
  }
}

Resource