기타 업무 해결 내용
MAC NVM 명령어
nvm ls : 현재 사용중인 version 및 install 된 node 확인
nvm use { version } : node version 변경
nvm alias default { version } : node default version 변경
nvm ls-remote : install 가능한 node list 조회
핸드폰 번호 정규식
^01([0|1|6|7|8|9])([0-9]{3,4})([0-9]{4})$
앞은 01만 입력 가능하고 3번째 자리는 0,1,6,7,8,9 만 입력 가능
뒤의 중앙자리는 0-9까지 되며, 3~4자리 입력이 되어야 함
Mac 환경 Chrom CORS 무시 설정 및 실행용 명령어
open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
Button ON OFF modal
// main
const CustomDownloadModal = () =>{
const [modalController, setModalController] = useState('')
console.log("modalController : ",modalController)
return (
<div className={`container-modal ${modalController}`}>
<Button onClick={()=> {setModalController('modal-open')}} className="btn-modal">Open Modal</Button>
<div className="modal-modal">
<div className="header">This is a full-width modal with a title
</div>
<div className="body-modal">
<p>And here is all its contents.</p>
<Button onClick={()=> {setModalController('')}} className="btn-modal">Close</Button>
</div>
</div>
</div>
)
}
//MultiDownLoad 용 Css
body-modal {
color: #333;
font-family: Lato;
font-weight: 300;
text-align: center;
background: #333;
}
.container-modal > .btn-modal {
margin: 60px;
padding: 20px 40px;
font-size: 30px;
border-radius: 40px;
}
.modal-modal {
background: #fff;
width: 20%;
height: 20%;
border: #0a0a0a 1px solid;
margin: 0;
padding: 0;
overflow-y: auto;
transition: all 600ms cubic-bezier(0.86, 0, 0.07, 1);
top: 100%;
right: 0;
position: fixed;
text-align: left;
.header {
padding:20px;
border-bottom: 1px solid #ddd;
font: 300 24px Lato;
position: relative;
}
.body {
padding: 20px;
font: 300 16px Lato;
}
}
.btn-modal {
background: linear-gradient(to right, rgb(220, 227, 91), rgb(69, 182, 73));
padding: 2px 10px;
display: inline-block;
border-radius: 5px;
margin: 0px 0;
color: #fff;
position: relative;
//transition: all .4s ease;
cursor: pointer;
&:hover {
box-shadow: 0 3px 15px rgba(0,0,0,0.2);
}
}
.container-modal.modal-open .modal-modal {
top: 0px;
}
map을 통해 반환 된 Array를 풀어 하나의 객체 배열로 만들고자 할떄
const a = [
...[
{ header: 'test', value: 'AAA' },
{ header: 'test', value: 'AAA' },
{ header: 'test', value: 'AAA' },
],
...[
{ header: 'test', value: 'BBB' },
{ header: 'test', value: 'BBB' },
{ header: 'test', value: 'BBB' },
],
]
console.log('a: ', a) // [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
const tableData = [
...serverList.map((server, index) => [
{ header: `Server Name #${index + 1}`, value: server.alias },
{ header: `Server Name #${index + 1}`, value: server.port },
{ header: `Server Name #${index + 1}`, value: server.serverUrl },
{
header: `Server Name #${index + 1}`,
value: (
<div className={'flex flex-row justify-content-between'}>
<label>{serverStatusLabel(server.serverStatus)}</label>
<InputSwitch checked={server.serverStatus} onChange={event => serverStatusChange(event, server)} />
</div>
),
},
]),
]
console.log('tableData : ', tableData) // (4) [{…}, {…}, {…}, {…}] (4) [{…}, {…}, {…}, {…}]
위와 같이, 서버에서 전달 받은 값을 하나의 객체로 만들려고 할때 map을 사용하니 개발자가 의도한대로 출력되지 않았다.
이떄는 아래와 같이 map이 아닌 flatMap을 이용하여 해결할수 있다.
...serverList.flatMap((server, index) => [
댓글
이름만 적고 남길 수 있어요