2021년 5월 20일 목요일

react button 파라미터 전달방법 및 undefined 비교 방법

 1. 파라미터 없이 버튼 click 이벤트

<Button onClick={saveLoc}>저장</Button>
const saveLoc = ()=>{
    Axios.post call
}

2. 파라미터 있는 버튼 click 이벤트
  -> 함수형으로 작성
  -> 함수형으로 작성하지 않으면 호출되지 않아도 로딩시 자동실행됨
<Button onClick={()=>delLoc(row)}>삭제</Button>
const delLoc = (item) =>{
const body = {
seq: item.seq
}
    Axios call
}
----
undefined 비교 방법
-> props.user.userData !== undefined && logic

댓글 없음:

댓글 쓰기