notes

React.note vs useMemo2020. 7. 10.

React.memo

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

useMemo

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

flex2020. 7. 9.

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>.

sourceViewController -> source2020. 7. 6.

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)
        }
    }

`Could not insert new outlet connection` error2020. 7. 5.

문제

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

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

해결

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

Tags