---
title: "Comment by Ákos Kőműves on \"How debugging for accessibility helped me finally understand useRef\" | Hashnode"
description: "Accessibility is super important. I like navigating with keys only. However, in React, you will most likely not use something like this in production. The custo"
url: "https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2"
---

[Discussion](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352)

Comment [How debugging for accessibility helped me finally understand useRef](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352)

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Mar 10, 2023](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2)

Accessibility is super important. I like navigating with keys only.

However, in React, you will most likely not use something like this in production.

The custom hook's useEffect doesn't have a dependency array, meaning it will run after every re-render of the component. If you put a console.log into the useEffect inside your hook, you'll see that initially, it runs 10 times. After adding 10 tasks, it ran 67 times! The other thing is that you don't need that hook - it's just wrapping around useRef anyway.

Because you know you want to re-focus on the listHeadingRef after the user clicks delete, you can just put that code into your deleteTask function.

function deleteTask(id) { const remainingTasks = tasks.filter((task) => id !== task.id); setTasks(remainingTasks); listHeadingRef.current.focus(); }

This will save you from the constantly re-running hook, and you can remove the entire useEffect, making your code easier to understand and change.

Hope this was helpful.

[Julia Undeutsch](https://hashnode.com/@YuriDevAT)

[Mar 10, 2023](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2#reply-640b10aa2043b31f181c069d)

Thank you so much for your reply. I will try it out. :) I still have to learn a lot about react, but for this article, accessibility was the main point.

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Mar 10, 2023](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2#reply-640b2a262043b31f181c0b38)

It's super important, especially for people learning React, to understand when they need to use certain mechanisms of React and when the same mechanisms are not just useless but even decremental in performance.

So I thought I'd give you some ideas on how you could write better React code, regardless of accessibility.

Thanks for reading my useless code review. 😄

[Julia Undeutsch](https://hashnode.com/@YuriDevAT)

[Mar 12, 2023](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2#reply-640d7f3b15cd01486d227333)

[Ákos Kőműves](https://hashnode.com/@akoskm) Oh no, please don't get me wrong! I appreciate your comment so much ! Only because I know I am not that good at React I wanted the blog post to be about the accessibility issue rather than the code itself, that's all. I already implemented the delete function you posted and checked with dev tools and console.log. Thank you so much for helping me making my code better. :)

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Mar 12, 2023](https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352/comment/640ad91ee3de6419e7484ea2#reply-640d8a09325cff4782a1824d)

No worries [Julia Undeutsch](https://hashnode.com/@YuriDevAT), and thanks for the follow-up. :) I rarely comment on blog posts, but you put much effort into this, so I thought I chime in with something useful. :)
