How to Improve Your ReactJS Code - Tips for Code Readability and Performance
1. Use Constants : 상수 사용하기 자바스크립트에서는, const 키워드를 통해 상수를 선언할 수 있다. 이것은, 같은 값을 재선언해주는 것을 방지해준다. 그래서 상수는 API keys나, 다른 비슷한 values를 저장하는데 유용하다. (API keys, URLs, Content) 모든 리액트 프로젝트에서, strings(content)을 하드코딩하는 건 지양해야한다/피해야한다. 이렇게 하면 UI, data, content를 서로 구분해줘서 프로젝트를 좀 더 유지보수성, 가독성, 확장성을 더 좋게 해준다. 많은 사이트들이 다양한 언어를 지원한다. 그래서 각각의 언어에 맞는 상수 파일이 있을 것이다. 상수 파일을 만드는 방법: 상수는 단순히 keys & values가 있는 자바스크립트 객체이..
2023. 11. 19.