Debounce Requests in React Router v7


React Router Tip

Debounce Requests in React Router v7

Have you ever implemented a search input filter for table or grid of data in your app that needs to initiate fetching new, filtered, data? If you want to initiate the requests as the user changes the filter value without having to manually click a submit button you likely want to debounce those requests. Do you use a debounce hook and resort to useEffect to kick of requests?? No! There's a much easier way that doesn't involve adding a single hook to your components. Let me show you exactly how in ​this video​. Or you can ​read the blog post here.

Currently Reading

I'm a big fan of books. Fiction, non-fiction doesn't matter. If it's compelling, I'm down. I just finished The River of Doubt by Candice Millard. It's about Teddy Roosevelt and his crew's adventurous trip down an uncharted tributary in the Amazon. It's an incredible story filled with mosquitoes, piranhas, malaria, drowning, hostile Indians, murder, and starvation, among other things. Pretty much everything that could go wrong does but somehow they make it out. It's a story of tribulation but also triumph. Roosevelt was known for doing hard things just for the sake of them being difficult. There's a lot of psychological benefit to just doing hard stuff. That feeling of accomplishment is euphoric. This book isn't only just really entertaining but an excellent reminder to not just coast by in life. Highly recommend both this perspective and the book.


Is there anything React Router related you'd like me to cover? What are you working on? Reading anything good? Reply back to this email. I'd love to hear from ya.

Have a stellar Monday ✌️

ProgrammingAreHard

For developers looking to learn useful tips and tricks.

Read more from ProgrammingAreHard

React Router Guide Untangling dialogs in React Router I have been struggling with determining how to best implement dialogs in React Router apps for years: useState to control their open state Forms vs fetchers for data submissions resource routes to form data(<select> options) useEffect for listening for the action data to close the dialog useEffect for listing for a toast message There's a lot to consider. However, tons of these problems go away if you move dialogs into their own dedicated...

React Router Guide Contributing Callsite Revalidation Opt-out to React Router If you’ve used React Router’s data APIs, you’ve probably noticed it revalidates all your loaders after mutations, even when you know that’s completely unnecessary. I got tired of implementing shouldRevalidate functions that ended up feeling really awkward. I found an old proposal from Ryan Florence in GitHub, and decided to take a crack at implementing it myself. A few months and one merged PR later, it shipped in...

React Router Guide How to execute api requests in React Router There's not a lot of opinions on how to structure code that interacts with apis in React Router apps. This is what I've come up with and the post I wish existed before I started using React Router's actions/loaders with my existing api(and if middleware existed back then). Check out the article here. Have a great Tuesday ✌️ Unsubscribe · Preferences