notes

2020. 7. 20.
google fonts에서 특정 캐릭터만 불러오기

google fonts를 url로 불러오는 방식으로 사용시 unicode-range를 사용할 수 없다. query string 옵션으로 subset 혹은 text를 줄 수 있다.

subset

subset은 언어 기준으로, 영문에만 특정 폰트를 적용하고 싶을 경우 사용한다. Roboto를 영문과 숫자에만 쓰고 싶다면? https://fonts.googleapis.com/css2?family=Roboto&subset=latin 이라고 하면 된다.

text

text가 좀 더 재밌는데, 개별 캐릭터를 옵션으로 추가할 수 있다. 예를 들어 Roboto를 0과 1에만 쓰고 싶다면?

https://fonts.googleapis.com/css2?family=Roboto&text=01 으로 요청하면 된다.

2020. 7. 10.
React.note vs useMemo

React.memo

  • Higher order component.
  • prop change만을 체크함. 감싼 컴포넌트 안에 useState, useContext등이 있다면, 역시 해당 state 변경에 따라 rerender됨.

useMemo

  • Hook.
  • deps array에 포함된 deps가 변경되지 않으면 memoized value를 반환하는 함수.

2020. 7. 9.
flex

flex

flex-grow, flex-shrink, + flex-basis의 shorthand이다.

syntax

  • One-value syntax: the value must be one of:
    • a <number>: In this case it is interpreted as flex: <number> 1 0; the <flex-shrink> value is assumed to be 1 and the <flex-basis> value is assumed to be 0.
    • one of the keywords: none, auto, or initial.
  • Two-value syntax: the first value must be a <number> and it is interpreted as <flex-grow>. The second value must be one of:
    • a <number>: then it is interpreted as <flex-shrink>.
    • a valid value for width: then it is interpreted as <flex-basis>.
  • Three-value syntax: the values must be in the following order:
    • a <number> for <flex-grow>.
    • a <number> for <flex-shrink>.
    • a valid value for width for <flex-basis>.

2020. 7. 6.
sourceViewController -> source

Implement Navigation을 진행하다가 아래 워닝을 만났다.

Screen Shot 2020-07-07 at 6 32 27

    //MARK: Actions
    @IBAction func unwindToMealList(sender: UIStoryboardSegue) {
-        if let sourceViewContoller = sender.sourceViewController as? MealViewController, let meal = sourceViewContoller.meal {
+        if let sourceViewContoller = sender.source as? MealViewController, let meal = sourceViewContoller.meal {
            // Add new meal.
            let newIndexPath = IndexPath(row: meals.count, section: 0)
            meals.append(meal)
            tableView.insertRows(at: [newIndexPath], with: .automatic)
        }
    }
    //MARK: Actions
    @IBAction func unwindToMealList(sender: UIStoryboardSegue) {
-        if let sourceViewContoller = sender.sourceViewController as? MealViewController, let meal = sourceViewContoller.meal {
+        if let sourceViewContoller = sender.source as? MealViewController, let meal = sourceViewContoller.meal {
            // Add new meal.
            let newIndexPath = IndexPath(row: meals.count, section: 0)
            meals.append(meal)
            tableView.insertRows(at: [newIndexPath], with: .automatic)
        }
    }

2020. 7. 5.
`Could not insert new outlet connection` error

문제

FoodTracker를 신나게 만드는 중이었는데, save 버튼을 MealViewController에 연결시키려던 순간!

위와 같은 메시지를 보여주면서 안되는 경우가 생겼다.

해결

  1. cmd+shift+K를 눌러 product를 clean 한다.
  2. cmd+R로 build + run을 한다.
  3. 한 번 해본다.
  4. 안되면 xcode를 재시작한다.