React_ES6 모듈로 파일 분리하여 코드 클린하게 하기
ES6 Module named : importing name should be same default : you can customise importing name 1. named import // src/books.js export const books = [ { author: 'Charles Dickens', title: 'Interesting Topics', img: './images/book-1.jpg', id: 1, }, { author: 'Laura Dave', title: 'The Last Thing He Told Me', img: './images/book-2.jpg', id: 2, }, ]; // src..
2023. 4. 24.
React_prop으로 받아온 함수 작동 안되는 문제. 래퍼 함수, 익명 함수로 해결하기
문제. 잘못된 예시 // src/index.js import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; const books = [ { author: 'Charles Dickens', title: 'Interesting Topics', img: './images/book-1.jpg', id: 1, }, { author: 'Laura Dave', title: 'The Last Thing He Told Me', img: './images/book-2.jpg', id: 2, }, ]; const BookList = () => { const getBook = (id) => { const book = book..
2023. 4. 24.