---
title: "Discussion on \"How debugging for accessibility helped me finally understand useRef\" | Hashnode"
description: "Discussion on \"How debugging for accessibility helped me finally understand useRef\". or, how my heart wanted to solve accessibility problems so badly that it finally clicked."
url: "https://hashnode.com/posts/how-debugging-for-accessibility-helped-me-finally-understand-useref/6409f6229bbd1512a1b06352"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How debugging for accessibility helped me finally understand useRef](https://yuridevat.hashnode.dev/how-debugging-for-accessibility-helped-me-finally-understand-useref?utm_source=hashnode&utm_medium=feed)

or, how my heart wanted to solve accessibility problems so badly that it finally clicked.

Mar 9, 2023 · 8 min read · yuridevat.hashnode.dev  
Updated Mar 12, 2023  
Read the article

-   [#debuggingfeb](https://hashnode.com/tag/debuggingfeb)
-   [#accessibility](https://hashnode.com/tag/accessibility)
-   [#a11y](https://hashnode.com/tag/a11y)
-   [#debuggingfeb-writeathon](https://hashnode.com/tag/debuggingfeb-writeathon)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

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

@YuriDevAT · Vienna Austria

  
[View profile](https://hashnode.com/@YuriDevAT)

Accessibility Advocate | Frontend Developer 🤓 | Content Creator | Blog Post Writer | Mentor 💟 | DE | EN | JP

👋 Selftaught Accessibility &amp; Frontend Developer 🙆 Improving the world with accessible web content ✍️ Content creator, Tips on how to get into tech

## Responses 7

Markdown supported · ⌘↵ to post

[Yazdun](https://hashnode.com/@Yazdun)

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

Great article Julia! That's an excellent example of making proper use of useRef 👍

[Md Faizan Alam](https://hashnode.com/@Faizan711)

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

Very well documented

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

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

Thank you :)

[MadCoding7588](https://hashnode.com/@CodingMaster)

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

i read your blog and it's amazing . I wanted some help , how did you add table of contents to your blog.

[Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

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

You can checkout this guide: [support.hashnode.com/en/articles/6541597-how-to-a…](https://support.hashnode.com/en/articles/6541597-how-to-add-a-table-of-content)

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

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

When you are going to publish your post, a panel appear with several settings, like adding SEO, Thumbnail, url, as well as automatically adding a table of content

[Massimo Baffoni](https://hashnode.com/@AnotherCodingGuy)

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

Nice to see other developers working on accessibility. I've started writing here for the same reason.

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

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

That's nice to hear, Massimo.

[Á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.

[Á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. :)

[Sandeep Panda](https://hashnode.com/@sandeep)

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

Pretty interesting! Thanks for your contribution to DebuggingFeb. :)

[Abdul-Razak, Jibrilla](https://hashnode.com/@zakitworld)

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

Learned
