


import React from 'react';
const Button = ({ onClick, children }) => {
return <button onClick={onClick}>{children}</button>;
};
export default Button;
import axios from 'axios';
const fetchData = async () => {
try {
const response = await axios.get('/example');
return response.data;
} catch (error) {
console.error('Error : ', error);
}
};
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
...
// EX> Jest
test('adds 1 + 2 to equal 3', () => {
expect(1 + 2).toBe(3);
});
src/
├── components/
│ ├── Header.js
│ ├── Sidebar.js
│ └── ...
├── utils/
│ ├── api.js
│ ├── helpers.js
│ └── ...
└── ...
// 리팩토링 이전
const total = items.reduce((acc, item) => {
if (item.status === 'completed') {
acc += item.price * item.quantity;
}
return acc;
}, 0);
// 리팩토링 이후
const completedItems = items.filter(item => item.status === 'completed');
const total = completedItems.reduce((acc, item) => acc + item.price * item.quantity, 0);
[출처] 책 - '클린 아키텍쳐'