카테고리 없음

리액트를 다루는 기술 - 일정 관리 웹 어플리케이션

Choi May 2018. 10. 30. 09:07

"리액트를 다루는 기술" 책을 읽고 정리 ( 저자 : 김민준 )

저자 블로그 : https://velopert.com/reactjs-tutorials

저자 블로그 :  https://velog.io/@velopert/tags/react


[10장] 일정관리 웹 어플리케이션

-프로젝트 셋팅-

1. 프로젝트 생성

$ create-react-app todo-list

생성 후, index.js 와 serviceWorker.js 남기고 나머지 파일 삭제

2. css Module 및 sass 적용

$ yarn eject

yarn add sass-loader node-sass classnames

3. webpack 설정 파일 수정

- webpack.config.dev.js 내 수정

- 바뀌기 전 설정 내용

{

            test: sassRegex,

            exclude: sassModuleRegex,

            use: getStyleLoaders({ importLoaders: 2 }, 'sass-loader'),

            }

- 바뀐 후 설정 내용 (USE 부분이 바뀜)

  {

            test: sassRegex,

            exclude: sassModuleRegex,

            use: getStyleLoaders({ importLoaders: 2 }).concat({

             loader: require.resolve('sass-loader'),

             options: {

               includePaths: [paths.appSrc + '/styles']

             }

           })

         }

4. open-color 적용

$ yarn add open-color

5. 폴더 생성

src/styles 디렉토리에 utils.scss 생성 후 import

@import '~open-color/open-color';   

6. 메인 스타일 지정 ( 위치 : src/styles/main.scss)

@import 'utils';


body {

  background: $oc-gray-1;

  margin:0px;

}

7. index.js 수정

css 부분과 App.js 폴더 위치 변경

import './styles/main.scss';

import App from './component/App';

8. App 생성

src/component 에 App.js 생성

import React, { Component } from 'react';


class App extends Component {

  render() {

    return (

      <div>

      일정관리

      </div>

    );

  }

}


export default App;



### yarn start로 로컬 서버를 띄우고, 화면이 잘 뜨는지 확인!!

* 필요한 컴포넌트 

- PageTemplate(메인화면), TodoInput(할일 받기), TodoItem(할일), TodoList(할일을 리스트로 뿌림)


-UI 셋팅-

9. PageTemplate 컴포넌트 만들기  ( App.js 에 추가 )

- git : https://github.com/velopert/learning-react/tree/master/10/todo-list/src/components/PageTemplate

src/component/PageTemplate 폴더 내 index.js, PageTemplate.js, PageTemplate.scss 생성




### 화면 확인 ( 일정 관리 <br> 안녕하세요  떴는지..)


10. todoInput 컴포넌트 생성  ( App.js 에 추가 )

- git : https://github.com/velopert/learning-react/blob/master/10/todo-list/src/components/TodoInput

- 위치 : src/component/TodoInput




11. TodoItem 컴포넌트 생성  ( App.js 에 추가 안함 TodoList에 추가)

- git: https://github.com/velopert/learning-react/tree/master/10/todo-list/src/components/TodoItem

- 위치 : src/component/TodoItem




12. TodoList

- git : https://github.com/velopert/learning-react/tree/master/10/todo-list/src/components/TodoList

- 위치 : src/components/TodoList



-status 셋팅-

13. todoInput 값 변경 적용 작업


14. 초기 일정 데이터 정의 및 랜더링

- 리스트 노출을 위한 App.js 수정

- todoList.js 수정


15. 데이터 추가


16. 체크박스 활성화/비활성화



17. 데이터 제거

- App.js 에 Remove 함수 넣어주면 됨



- 이때 그냥 지우기를 하면 안 지워짐.