이대로 따라함!!👇🏻
https://wonillism.tistory.com/185
vi 에디터 처럼 키보드로 조작 가능하게해줌!
vi cheatsheet
주로 알아야 할 단축 키
- h
: 왼쪽으로 한 칸 이동
- j
: 아래로 한 칸 이동
- k
: 위로 한 칸 이동
- l
: 오른쪽으로 한 칸 이동
- w
: 다음 단어 시작으로 점프
- gg
: 문서 첫 줄 시작으로 점프
- 5gg
or 5G
: 5번째 행 시작으로 점프
- u
: 실행취소
- yy
: 한 행 복사하기
- dd
: 한 행 잘라내기
mkdir .github
mkdir workflows
touch build_verification.yml
src
┣ api
┃ ┣ axios
┃ ┃ ┗ AxiosTodoService.ts
┃ ┗ TodoService.ts
┣ components
┃ ┣ todoitemcontainer
┃ ┃ ┣ TodoItem.tsx
┃ ┃ ┗ TodoItemView.tsx
┃ ┣ todolistcontainer
┃ ┃ ┣ TodoList.tsx
┃ ┃ ┗ TodoListView.tsx
┃ ┗ viewcontainer
┃ ┃ ┣ Card.tsx
┃ ┃ ┣ CheckBtn.tsx
┃ ┃ ┣ IconBtn.tsx
┃ ┃ ┗ Text.tsx
┣ page
┃ ┗ Mainpage.tsx
┣ App.tsx
┗ index.tsx
아래와 같이 벨로퍼트 리액트 깃북의 투두리스트 UI로 진행해보려한다.
그렇다면, 필요한것은 ? 최대한 분리할 수 있는 컴포넌트는 다 분리해보기!
또한 디자인 패턴에 대해서도 생각해보았다.
View Asset Component
VAC : state 없이 view 만 하는 역할을 함
View Component : 상태관리, 기능을 담당할 함수 모음이라고 생각 함.
┃ ┣ todoitemcontainer
┃ ┃ ┣ TodoItem.tsx
┃ ┃ ┗ TodoItemView.tsx
지금은 json-server의 공부도 필요한 상황이라, 먼저 json-server로 연결해보고, 추후 indexedDb로 바꿀 예정이다.
따라서, DIP에 따라 api 폴더 구조를 구상하였다.
"scripts": {
"start": "react-scripts start & npm run server",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"server": "json-server --watch ./database/database.json --port 8000"
},
{
"todos": [
{
"id": 1,
"hi": "hihihi",
"number": "9447"
},
{
"id": 2,
"hi": "Byebyebye",
"number": "04077"
}
]
}
interface 설정
export interface TodoService {
getTodoItems(): Promise<Array<any>>;
changeTodoItem(item: any): Promise<void>;
}
import axios from "axios";
import { TodoService } from "../TodoService";
const todoAxios = axios.create({
baseURL: "http://localhost:8000",
});
export class AxiosTodoService implements TodoService {
async changeTodoItem(item: any): Promise<void> {
const response = await todoAxios.put(`/todos/${item.id}`);
}
async getTodoItems(): Promise<Array<any>> {
const response = await todoAxios.get("/todos");
return response.data;
}
}
url : http://localhost:8000/todos
import React, { useEffect, useState } from "react";
import { AxiosTodoService } from "../../api/axios/AxiosTodoService";
type Props = {};
const TodoList = (props: Props) => {
const [item, setItem] = useState([]);
useEffect(() => {
const todoService = new AxiosTodoService();
todoService.getTodoItems().then((data: any) => {
setItem(data);
});
}, []);
useEffect(() => {
console.log(item);
}, [item]);
return <div>TodoList</div>;
};
export default TodoList;
우연히 블로그를 왔는데 제 글을 보시고 세팅하셨네요! 감사합니다 ㅎㅎ
혹시나 잘 안되는거 있으면 글 남겨주세요 ㅎㅎ