2020. 7. 21.`nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local" Run `npm config delete prefix` or `nvm use --delete-prefix * --silent` to unset it.`
?
system에 설치된 node랑 충돌하는 것
!
brew uninstall --ignore-dependencies node
brew uninstall --ignore-dependencies node
2020. 7. 21.how to stash single file
git stash -- <filename>
git stash -- <filename>
git stash push -m "<message>" <filename.ext>
git stash push -m "<message>" <filename.ext>
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. 14.Warning: Cannot update a component (*) while rendering a different component (*).
setState
에서 다른 컴포넌트의 setState
를 호출할 경우 뜨는 경고 메시지로, 16.13.0
에서 추가되었다. prop으로 넘어온 함수가 setState
를 하는 경우에 발생한다.
해당 케이스가 발생하면, 호출하는 컴포넌트에서 useEffect
로 감싸라고 공식 사이트에서 안내해주고 있다.
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 asflex: <number> 1 0;
the<flex-shrink>
value is assumed to be1
and the<flex-basis>
value is assumed to be0
. - one of the keywords:
none
,auto
, orinitial
.
- a
- 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>
.
- a
- 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>
.
- a
2020. 7. 8.String interpolation produces a debug description for an optional value; did you mean to make this explicit?
default:
- fatalError("Unexpected Segue identifier; \(segue.identifier)")
+ fatalError("Unexpected Segue identifier; \(String(describing: segue.identifier))")
default:
- fatalError("Unexpected Segue identifier; \(segue.identifier)")
+ fatalError("Unexpected Segue identifier; \(String(describing: segue.identifier))")
2020. 7. 6.Delegation Pattern
https://en.wikipedia.org/wiki/Delegation_pattern
class Rectangle(val width: Int, val height: Int) {
fun area() = width * height
}
class Window(val bounds: Rectangle) {
// Delegation
fun area() = bounds.area()
}
class Rectangle(val width: Int, val height: Int) {
fun area() = width * height
}
class Window(val bounds: Rectangle) {
// Delegation
fun area() = bounds.area()
}
Links
2020. 7. 6.sourceViewController -> source
Implement Navigation을 진행하다가 아래 워닝을 만났다.
//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
에 연결시키려던 순간!

위와 같은 메시지를 보여주면서 안되는 경우가 생겼다.
해결
cmd+shift+K
를 눌러 product를 clean 한다.cmd+R
로 build + run을 한다.- 한 번 해본다.
- 안되면 xcode를 재시작한다.