codestates / codestates/Memory-It
[Error Handling] Cannot read properties of undefined (reading 'preventDefault')
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?
+ onClick에 두개의 함수를 실행시킬 때 나타나는 에러.
### 에러 메시지
```
uncaught TypeError: Cannot read properties of undefined (reading 'preventDefault')
```
### 에러 핸들링 방법
+ onClick에 두개의 함수를 실행시킬 때 나타나는 에러.
+ It happens because of an incorrect binding of this. Sometimes the scope is not setup correctly which causes the event object to be undefined.
+ 가장 간단한 방법으로는 이벤트 파라미터를 넘겨주는 것이었다.
```jsx
{
onTest(e)
handleToPostingMapPage(e)
}} />
```
### 에러 핸들링을 위해 참고한 레퍼런스 링크
[How to Fix cannot read property preventdefault of undefined](https://www.jsdiaries.com/how-to-fix-cannot-read-property-preventdefault-of-undefined/)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.