/* 변수명 camelCase*/
const UserName = 'seongho Park' // X
const userName = 'seongho Park' // O
/* 상수 */
const fixedRate = // X
const FIXED_RATE = 0.3; // O
/* bad */
var level = function1(param1, param2);
const gauge = function2(param1 ,param2, param3);
/* good useMemo */
const {level, gauge} = useMemo(()=>{
const level = function1(param1, param2);
const gauge: function2(param1 ,param2, param3);
return {
level,
gauge
}
},[param1,parma2,param3])
const testUser = 'Nuvilabs';
// bad
const obj = {
testUser: testUser,
};
// good
const obj = {
testUser,
};
// bad
const obj = {
userId: 1,
testUser,
departmentId: 0,
loginDate,
};
// good
const obj = {
testUser,
userId: 1,
departmentId: 0,
loginDate:'2020-00-00',
};
/* 함수명 동사로 시작 */
const dateHandler = (date) => new Date(); // X
const handleDate = (date) => new Date(); // O
/* one line function */
// bad
<button onClick={() => alert('clicked')}>클릭</button>
// good
const handleClick = () => alert('clicked');
<button onClick={handleClick}>클릭</button>
const {colorLevelArr, currentLevel} = useCallback(
createColorLevelArrAndCurrentLevel(zeroLeftover,zeroLeftoverToLevel, numOfUser),[zeroLeftover, numOfUser])
// 표현식이 아닌 선언식으로 작성
/* good case */
export default function MainComponent(props){
return(
<div>main component</div>
)
};
/* bad case */
const MainComponent (props) => {
return(
<div>main component</div>
)
};
export default ManiComponent;
// 자식 컴포넌트는 부모 컴포넌트 내에서 정의하지 않음
// bad
export function Parent(){
// (logic ...)
function Child(){
return (
<div>I am a child</div>
)
};
return(
<div>
<Child />
</div>
)
};
// good
function Child(){
return (
<div>I am a child</div>
)
};
export function Parent(){
// (logic...)
return (
<div>
<Child />
</div>
)
};
// 컴포넌트는 항상 대문자로 작성
// bad
const nameTag = () => {
return (
<div>박성호</div>
)
};
// good
const NameTag = () => {
return (
<div>박성호</div>
)
};
/* 컴포넌트 분리 */
// bad
function InformationBar (){
return (
<Container>
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
</Container>
)
};
// good
function UserInfo (){
return (
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
)
};
function Calendar (){
return (
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
)
};
function InformationBar (){
return (
<Container>
<UserInfo />
<Calendar />
</Container>
)
};
/* 조건에 따라 A 컴포넌트 렌더링: && 연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false);
// 참일 경우에만 '참입니다' 렌더링
return (
<div>
<div>참입니까</div>
{isTrue && <div>참입니다</div>}
</div>
)
};
/* 조건에 따라 A 컴포넌트 혹은 B 컴포넌트 렌더링: 삼항연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false)
// 참일 경우에는 '참입니다' 렌더링, 거짓일 경우에는 '거짓입니다' 렌다링
return (
<div>
<div>참입니까</div>
{isTrue ? <div>참입니다</div> : <div>거짓입니다</div>}
</div>
)
};
/* use self-closing tags */
<input type="text" onChange={handleText}></input> // X
<input type="text" onChange={handleText}/> // O
/* map 을 활용한 렌더링*/
const numbers = [1,2,3,4,5,6,7,8];
export function NumberList(){
return(
<div>
{numbers.map(number, index) => (
<div key={index}>
<div>번호: {number} </div>
</div>
)}
</div>
)
};
// 외부 모듈과 내부 모듈 구분
import lodash from'lodash';
import $ = from 'jquery';
import pluginFactory from '../../factories/pluginFactory';
import predicate from '../../helpers/predicate';
import raphaelRenderUtil from '../../plugins/raphaelRenderUtil';
/* 용도에 따른 구분 */
import React, {useState, useEffect, useCallback, useMemo} from 'react'
import ReactPlayer from 'react-player'
//components
import LeftInfo from './modules/left-info'
import RightInfo from './modules/right-info'
//assets
import bgImg from 'assets/images/background/background.png'
import { lv1Mp4, lv2Mp4 } from 'assets/video/background.video'
//styles
import styled from 'styled-components'
//contexts
import { useBgLevelContext, useNoLeftoverContext } from 'contexts/noLeftoverContext'
import { useDepartmentInfoContext } from 'contexts/noLeftoverContext'
//constant & funciton
import { STANDARD, VIEWPORT } from 'utils/constants/left-animal-list'
import {zeroLeftoverToLevel} from 'utils/functions/discernment'
const numberB = 777;
// Bad
if (numberB == '777') { //true
...
}
// Good
if (numberB === 777) {
...
}
/* 가급적 인라인보다는 styled-components 활용*/
// bad case
<div style={{ width: '100%', fontSize: '1.2rem', border="1px solid blue"}} />
// good case
<NameTag />
...
const NameTag = styled.div`
width: 100%;
font-size: 1.2rem;
border: 1px solid blue
`;
/*
여러 파일이 있을 경우 index.js
./cup.png
./factory.png
./trees.png
*/
export {default as cupImg} from "./cup.png"
export {default as factoryImg} from "./factory.png"
export {default as treesImg} from "./trees.png"
/* 변수명 camelCase*/
const UserName = 'seongho Park' // X
const userName = 'seongho Park' // O
/* 상수 */
const fixedRate = // X
const FIXED_RATE = 0.3; // O
/* bad */
var level = function1(param1, param2);
const gauge = function2(param1 ,param2, param3);
/* good useMemo */
const {level, gauge} = useMemo(()=>{
const level = function1(param1, param2);
const gauge: function2(param1 ,param2, param3);
return {
level,
gauge
}
},[param1,parma2,param3])
const testUser = 'Nuvilabs';
// bad
const obj = {
testUser: testUser,
};
// good
const obj = {
testUser,
};
// bad
const obj = {
userId: 1,
testUser,
departmentId: 0,
loginDate,
};
// good
const obj = {
testUser,
userId: 1,
departmentId: 0,
loginDate:'2020-00-00',
};
/* 함수명 동사로 시작 */
const dateHandler = (date) => new Date(); // X
const handleDate = (date) => new Date(); // O
/* one line function */
// bad
<button onClick={() => alert('clicked')}>클릭</button>
// good
const handleClick = () => alert('clicked');
<button onClick={handleClick}>클릭</button>
const {colorLevelArr, currentLevel} = useCallback(
createColorLevelArrAndCurrentLevel(zeroLeftover,zeroLeftoverToLevel, numOfUser),[zeroLeftover, numOfUser])
// 표현식이 아닌 선언식으로 작성
/* good case */
export default function MainComponent(props){
return(
<div>main component</div>
)
};
/* bad case */
const MainComponent (props) => {
return(
<div>main component</div>
)
};
export default ManiComponent;
// 자식 컴포넌트는 부모 컴포넌트 내에서 정의하지 않음
// bad
export function Parent(){
// (logic ...)
function Child(){
return (
<div>I am a child</div>
)
};
return(
<div>
<Child />
</div>
)
};
// good
function Child(){
return (
<div>I am a child</div>
)
};
export function Parent(){
// (logic...)
return (
<div>
<Child />
</div>
)
};
// 컴포넌트는 항상 대문자로 작성
// bad
const nameTag = () => {
return (
<div>박성호</div>
)
};
// good
const NameTag = () => {
return (
<div>박성호</div>
)
};
/* 컴포넌트 분리 */
// bad
function InformationBar (){
return (
<Container>
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
</Container>
)
};
// good
function UserInfo (){
return (
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
)
};
function Calendar (){
return (
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
)
};
function InformationBar (){
return (
<Container>
<UserInfo />
<Calendar />
</Container>
)
};
/* 조건에 따라 A 컴포넌트 렌더링: && 연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false);
// 참일 경우에만 '참입니다' 렌더링
return (
<div>
<div>참입니까</div>
{isTrue && <div>참입니다</div>}
</div>
)
};
/* 조건에 따라 A 컴포넌트 혹은 B 컴포넌트 렌더링: 삼항연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false)
// 참일 경우에는 '참입니다' 렌더링, 거짓일 경우에는 '거짓입니다' 렌다링
return (
<div>
<div>참입니까</div>
{isTrue ? <div>참입니다</div> : <div>거짓입니다</div>}
</div>
)
};
/* use self-closing tags */
<input type="text" onChange={handleText}></input> // X
<input type="text" onChange={handleText}/> // O
/* map 을 활용한 렌더링*/
const numbers = [1,2,3,4,5,6,7,8];
export function NumberList(){
return(
<div>
{numbers.map(number, index) => (
<div key={index}>
<div>번호: {number} </div>
</div>
)}
</div>
)
};
// 외부 모듈과 내부 모듈 구분
import lodash from'lodash';
import $ = from 'jquery';
import pluginFactory from '../../factories/pluginFactory';
import predicate from '../../helpers/predicate';
import raphaelRenderUtil from '../../plugins/raphaelRenderUtil';
/* 용도에 따른 구분 */
import React, {useState, useEffect, useCallback, useMemo} from 'react'
import ReactPlayer from 'react-player'
//components
import LeftInfo from './modules/left-info'
import RightInfo from './modules/right-info'
//assets
import bgImg from 'assets/images/background/background.png'
import { lv1Mp4, lv2Mp4 } from 'assets/video/background.video'
//styles
import styled from 'styled-components'
//contexts
import { useBgLevelContext, useNoLeftoverContext } from 'contexts/noLeftoverContext'
import { useDepartmentInfoContext } from 'contexts/noLeftoverContext'
//constant & funciton
import { STANDARD, VIEWPORT } from 'utils/constants/left-animal-list'
import {zeroLeftoverToLevel} from 'utils/functions/discernment'
const numberB = 777;
// Bad
if (numberB == '777') { //true
...
}
// Good
if (numberB === 777) {
...
}
/* 가급적 인라인보다는 styled-components 활용*/
// bad case
<div style={{ width: '100%', fontSize: '1.2rem', border="1px solid blue"}} />
// good case
<NameTag />
...
const NameTag = styled.div`
width: 100%;
font-size: 1.2rem;
border: 1px solid blue
`;
/*
여러 파일이 있을 경우 index.js
./cup.png
./factory.png
./trees.png
*/
export {default as cupImg} from "./cup.png"
export {default as factoryImg} from "./factory.png"
export {default as treesImg} from "./trees.png"
/* 변수명 camelCase*/
const UserName = 'seongho Park' // X
const userName = 'seongho Park' // O
/* 상수 */
const fixedRate = // X
const FIXED_RATE = 0.3; // O
/* bad */
var level = function1(param1, param2);
const gauge = function2(param1 ,param2, param3);
/* good useMemo */
const {level, gauge} = useMemo(()=>{
const level = function1(param1, param2);
const gauge: function2(param1 ,param2, param3);
return {
level,
gauge
}
},[param1,parma2,param3])
const testUser = 'Nuvilabs';
// bad
const obj = {
testUser: testUser,
};
// good
const obj = {
testUser,
};
// bad
const obj = {
userId: 1,
testUser,
departmentId: 0,
loginDate,
};
// good
const obj = {
testUser,
userId: 1,
departmentId: 0,
loginDate:'2020-00-00',
};
/* 함수명 동사로 시작 */
const dateHandler = (date) => new Date(); // X
const handleDate = (date) => new Date(); // O
/* one line function */
// bad
<button onClick={() => alert('clicked')}>클릭</button>
// good
const handleClick = () => alert('clicked');
<button onClick={handleClick}>클릭</button>
const {colorLevelArr, currentLevel} = useCallback(
createColorLevelArrAndCurrentLevel(zeroLeftover,zeroLeftoverToLevel, numOfUser),[zeroLeftover, numOfUser])
// 표현식이 아닌 선언식으로 작성
/* good case */
export default function MainComponent(props){
return(
<div>main component</div>
)
};
/* bad case */
const MainComponent (props) => {
return(
<div>main component</div>
)
};
export default ManiComponent;
// 자식 컴포넌트는 부모 컴포넌트 내에서 정의하지 않음
// bad
export function Parent(){
// (logic ...)
function Child(){
return (
<div>I am a child</div>
)
};
return(
<div>
<Child />
</div>
)
};
// good
function Child(){
return (
<div>I am a child</div>
)
};
export function Parent(){
// (logic...)
return (
<div>
<Child />
</div>
)
};
// 컴포넌트는 항상 대문자로 작성
// bad
const nameTag = () => {
return (
<div>박성호</div>
)
};
// good
const NameTag = () => {
return (
<div>박성호</div>
)
};
/* 컴포넌트 분리 */
// bad
function InformationBar (){
return (
<Container>
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
</Container>
)
};
// good
function UserInfo (){
return (
<div>
<div>이름: 김누비</div>
<div>나이: 21세</div>
</div>
)
};
function Calendar (){
return (
<div>
<div>2021년</div>
<div>5월</div>
<div>28일</div>
</div>
)
};
function InformationBar (){
return (
<Container>
<UserInfo />
<Calendar />
</Container>
)
};
/* 조건에 따라 A 컴포넌트 렌더링: && 연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false);
// 참일 경우에만 '참입니다' 렌더링
return (
<div>
<div>참입니까</div>
{isTrue && <div>참입니다</div>}
</div>
)
};
/* 조건에 따라 A 컴포넌트 혹은 B 컴포넌트 렌더링: 삼항연산자 */
export default function ConditionalRendering (){
const [isTrue, setIsTrue] = useState(false)
// 참일 경우에는 '참입니다' 렌더링, 거짓일 경우에는 '거짓입니다' 렌다링
return (
<div>
<div>참입니까</div>
{isTrue ? <div>참입니다</div> : <div>거짓입니다</div>}
</div>
)
};
/* use self-closing tags */
<input type="text" onChange={handleText}></input> // X
<input type="text" onChange={handleText}/> // O
/* map 을 활용한 렌더링*/
const numbers = [1,2,3,4,5,6,7,8];
export function NumberList(){
return(
<div>
{numbers.map(number, index) => (
<div key={index}>
<div>번호: {number} </div>
</div>
)}
</div>
)
};
// 외부 모듈과 내부 모듈 구분
import lodash from'lodash';
import $ = from 'jquery';
import pluginFactory from '../../factories/pluginFactory';
import predicate from '../../helpers/predicate';
import raphaelRenderUtil from '../../plugins/raphaelRenderUtil';
/* 용도에 따른 구분 */
import React, {useState, useEffect, useCallback, useMemo} from 'react'
import ReactPlayer from 'react-player'
//components
import LeftInfo from './modules/left-info'
import RightInfo from './modules/right-info'
//assets
import bgImg from 'assets/images/background/background.png'
import { lv1Mp4, lv2Mp4 } from 'assets/video/background.video'
//styles
import styled from 'styled-components'
//contexts
import { useBgLevelContext, useNoLeftoverContext } from 'contexts/noLeftoverContext'
import { useDepartmentInfoContext } from 'contexts/noLeftoverContext'
//constant & funciton
import { STANDARD, VIEWPORT } from 'utils/constants/left-animal-list'
import {zeroLeftoverToLevel} from 'utils/functions/discernment'
const numberB = 777;
// Bad
if (numberB == '777') { //true
...
}
// Good
if (numberB === 777) {
...
}
/* 가급적 인라인보다는 styled-components 활용*/
// bad case
<div style={{ width: '100%', fontSize: '1.2rem', border="1px solid blue"}} />
// good case
<NameTag />
...
const NameTag = styled.div`
width: 100%;
font-size: 1.2rem;
border: 1px solid blue
`;
/*
여러 파일이 있을 경우 index.js
./cup.png
./factory.png
./trees.png
*/
export {default as cupImg} from "./cup.png"
export {default as factoryImg} from "./factory.png"
export {default as treesImg} from "./trees.png"