soywod / react-pin-field

📟 React component for entering PIN codes.
https://soywod.github.io/react-pin-field/
MIT License
412 stars 24 forks source link

Updated index.ts #41

Closed DSS3113 closed 3 years ago

DSS3113 commented 3 years ago

Added an if statement to the useEffect hook's return statement function to check if ref.current exists before removing its event listeners. I had this issue where my page component updated, removing the ReactPinField component and it raised an error saying that ref.current is null. Changing the code to this fixed it. Since the ReactPinField component is itself removed, there is no need to remove its event listeners as they'll automatically be removed by the garbage collector. (I hope my understanding is correct)

soywod commented 3 years ago

Thank you :tada: