avatar

Javascript 31

  • Published on
    ## 문제의 시작 문제의 시작은 [여기](/2019/06/17/typescript-type-enum-partial-record/) 였다. 내가 사용하는 코드는 아래와 같았다. ```typescript type GlobalColors = "Red" | "Blue" | "Green" | "Black"; // 기본값으로 색상을 선언한다. const enu...
  • Published on
    [원문-reactjs-interview-questions](https://github.com/sudheerj/reactjs-interview-questions) [1. Core React](/2019/08/13/reactjs-interview-questions-1/) [2. React - Router, Internationalization, Redux,...
  • Published on
    ### useReducer ```javascript const [state, dispatch] = useReducer(reducer, initialArg, init); ``` `useState`의 대체 함수다. 다수의 하윗 값을 만드는 복잡한 로직, 혹은 다음 state가 이전 state의 의존적인 경우에 쓴다. 뭐가 뭔지 모르겠으니까 예제를 보자. ...
  • Published on
    # Hooks API Hook은 react 16.8에서 추가된 개념으로, Hook을 시용하면 class를 갖성하지 않아도 state관리와 같은 react의 기능을 사용할 수 있다. ## 기본 Hook ### useState ```javascript const [state, setState] = useState(initialState); setStat...
  • Published on
    멍청이라 그런지 `reduce` 함수가 잘 이해 되지 않았다. ## Reduce ```javascript const list = [1, 2, 3, 4, 5]; const initValue = 10; const totalSum = list.reduce( (accumulator, currentValue, currentIndex, array) => { ...