Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

news-viewer project finished. code review start #42

Merged
merged 1 commit into from Nov 16, 2020
Merged

Conversation

RyanKor
Copy link
Owner

@RyanKor RyanKor commented Nov 16, 2020

벨로퍼트 News-API 뷰어 프로젝트 마무리

주안점

  1. 상태 관리를 위해 UseEffect를 굉장히 잘 활용하는 점

  2. 파일을 나눠서 코드 관리를 좀 더 용이하게 진행하는 점

  3. Todo App 보다 더 다양한 모듈을 활용하는 점

@RyanKor RyanKor self-assigned this Nov 16, 2020
Copy link
Owner Author

@RyanKor RyanKor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

news-api를 배우면서 최적화 작업을 어떻게 진행하는지 배울 수 있었다.

todo-app / news api만 잘 활용해도 프로젝트 완성도를 높일 수 있다.


import React from 'react'
import {Route} from 'react-router-dom'
import NewsPage from './components/NewsPage'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트 파일에서 만들어진 News page 값을 React-Router로 연결해 값을 받는다.

import styled from 'styled-components'
import {NavLink} from 'react-router-dom'

const categories = [
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NavLink (React Router) 에서 상단 네브바를 구성할 리터럴 객체 작업

import Categories from '../components/Categories'
import NewsList from '../components/NewsList'

const NewsPage = ({match}) =>{
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{match} 속성은 React-Router를 활용하면 가져오는 속성으로 url의 param을 가져온다.

@@ -3,11 +3,12 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {BrowserRouter} from 'react-router-dom'
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-router-dom 설정하기

@@ -0,0 +1,24 @@
import {useState, useEffect} from 'react'

export default function usePromise(promiseCreator, deps){
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

news api 정보의 대기, 로딩 완료, 실패를 가져오게끔 별도의 컴포넌트를 구성해 작업하는 파일

@RyanKor RyanKor merged commit 1e7410e into master Nov 16, 2020
@RyanKor
Copy link
Owner Author

RyanKor commented Nov 16, 2020

작업하면서 발생했던 에러 정리

문제점

$ yarn start를 했더니 아래와 같은 에러 코드를 발견했다.

Error : You gave us a visitor for the node type StaticBlock but it's not a valid type

별도로 설정 값에서 수동 작업했던 코드는 없었는데, 구글링을 통해 해당 에러 이유를 찾아보니 버전의 충돌이 발생한 것 같았다.

해결 방안

image

위와 같이 yarn 설정을 제거하고 다시 설치했더니 정상 작동했다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant