본문 바로가기
728x90

Programming/Javascript23

useSelector 호출 시점 React-Redux의 useSelector를 사용하면서 상태변경 시점에 대해 이론만 이해한 것 같은데 실전에 적용하지 못했습니다. 계속 문제가 발생하기에 잊지않으려 사례를 공유합니다. 문제점 React를 사용하면서 항상 헷깔렸던 점은 state의 상태가 언제 변경되는냐이다. 이미 state는 비동기적으로 바뀐다는 것을 알고 있었지만 계속 함수 내부에서 useState를 사용하면서 '왜 안바뀌지?'라는 실수를 반복하곤 했다 const [message, setMessage] = useState('안바꼈지롱'); function updateState = () => { setMessage("업데이트!") console.log(message) // 안바꼈지롱 }Redux를 사용하면서.. 2020. 11. 12.
VSCode로 Express 앱 디버깅하기 package.json 설정 "scripts": { "start": "node ./index.js", "debug": "nodemon --inspect ./app.js" } launch.json 설정 { "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Node: Nodemon", "processId": "${command:PickProcess}", "restart": true, "protocol": "inspector", }, ] } debug 모드로 실행 npm run debug nodemon --inspect ./app.js로 끝나는 pid 선택 참고 https://github.com/Micr.. 2020. 10. 22.
을/를 변환기 function eulruel(str) { const start = 44032; // 가 const end = 55203; // 힣 const lastCode = str.charCodeAt(str.length - 1); let toggle = false; if ( lastCode end ) return false; if ( (lastCode - start) % 28 == 0 ) toggle = true; return toggle ? `${str}를` : `${str}을` }참고 : https://gun0912.tistory.com/65 2020. 4. 28.
millisecond 날짜 변환 1578290155000은 UNIX 시간 (1970년 1월 1일 00:00:00)을 기준으로 2020-01-06 14:55:55까지의 millisecond 단위 new Date(1578290155000)는 한국 표준시를 리턴 Mon Jan 06 2020 14:55:55 GMT+0900 (한국 표준시) 보기 좋게 포멧하는 과정이 필요하다. const formateDate = sec => { const d = new Date(sec); return d.getFullYear() + '-' + dd(d.getMonth() + 1) + '-' + dd(d.getDate()) + ' ' + dd(d.getHours()) + ':' + dd(d.getMinut.. 2020. 1. 6.
Radio button in group just to make one of the radio button checked when the others are unchecked 이메일 구글 make user you should put the group of radio buttons in the same group id of fieldset (in this case I gave them group1), also give the same name of each button which is fieldset id 2019. 12. 3.
리액트 포트 변경 윈도우 package.json "scripts": { "start": "set PORT=8080 && react-scripts start" }맥 package.json "scripts": { "start": "PORT=8080 react-scripts start", } 2019. 11. 26.
728x90