πŸŽ‰πŸ₯³ Announcing #ReactLocation, a brand new router for React!

⏳ Async Loaders & Elements
πŸ”€ Parallelized
⏲️ Prefetching
πŸ—„ Caching
πŸ”Ž 1st-class Integrated Search Params API
πŸ—‚ Code-Splitting
⚠️ Error/Pending/Timing States
πŸͺ† Nested Layouts

react-location.tanstack.com

#TanStack
⏳ Async Route Loaders & Elements

Routes can define data dependencies and the elements they render as asynchronous functions that will be guaranteed to resolve before rendering the next location. The suspense is palpable! 😜
πŸ”€ Parallelized Loaders

"🎢 Don't go chasing waterfalls", not even the data-fetching ones!

Navigating through 3 loaders to a deep link out of the gate? By default, loaders and async elements for matched routes are all parallelized for efficiency. You can fetch serially, too πŸ€·β€β™‚οΈ
πŸ‘©β€πŸ³ Prefetching

Placeholder spinners are the worst! To get rid of them, just turn on prefetching for individual <Link />s, all of them, or even prefetch manually with `useLoadRoute`. No more spinners. Basic Caching. Auto garbage collection. Win win win.
πŸ—„ Optional Built-in/External Caching

Out of the box, active and pending route data is cached while you navigate, so only changing UI triggers data fetching. BUT WAIT, you can also use RL's basic maxAge caching for more, OR you can even integrate RL with tools like #ReactQuery!
πŸ”Ž 1st-class Integrated Search Params API

Search params are pure πŸ”₯-power when building apps so RL doesn't mess around. With 1st-class search param APIs everywhere, you'll *want* to put more state in the URL and your users will thank you for it every time they share or bookmark.
πŸ—‚ Code-Splitting

Table Stakes here, but we have to mention it. Code Splitting is of course supported, and the coolest part about it is that any code-splitting you do in RL doesn't change anything about parallelization, prefetching, etc. Ahh tsss... split it. Split it real good!
⚠️ Error States

Things don't always go as planned, so if your loaders πŸ’© out, you can provide error elements to handle them. After all, everybody πŸ’©, right?!
⏰ Pending States

Sometimes loaders can also be little 🐒, so pending states are a must. Time them for exactness to give a chance for that "suspense"-y feel, then fall back to the pending state. Heck, you can even force a pending state to show for a minimum amount of time!
πŸͺ† Nested Layouts

Again, table stakes here, but we have to mention it. If you don't know the benefits of nested layouts yet... first of all, what router have you been using for the last 7 years? πŸ˜‚ But seriously, they're fantastic.
πŸͺ Batched Navigation/Render

Putting state in the URL and async navigating can get a little 🌢️ for the URL and rerendering in large apps. "Routings a batch" 😜.

RL batches both URL updates and rerenders to your app to suss out every last bit of performance it can.
There's a handful of other awesome features like:

- Optional route filtering/ranking
- JSX-style routes for the "clean code"-ers

A a few more that are on the way, mainly completing the SSR story + examples
Thanks for your support and go check it out!

react-location.tanstack.com
We forgot to add (and document apparently) that React Location also ships with the beloved usePrompt() and <Prompt> hook and component!

The docs are now up to date :)

react-location.tanstack.com/docs/api#usepr…
Also, did you know that React Location is only 7.2kb gzipped? 🀯

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Tanner Linsley βš›οΈ Nozzle.io Rules!!! πŸ’ͺ

Tanner Linsley βš›οΈ Nozzle.io Rules!!! πŸ’ͺ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @tannerlinsley

15 Jul 20
@theefer @OliverJAsh I’ll respond more at my keyboard, but the simple solution to this is to adopt invalidation patterns over manual data normalization. Just invalidate all of the queries. They already know how to fetch the exact data they need.
@theefer @OliverJAsh Regardless of React Query or not, normalized caches on the front-end come with the upside of fetching less data and using the responses of mutations as much as possible. When you like a tweet, you just go find that tweet in your store and update it

...
@theefer @OliverJAsh This situation works fine if that action doesn't have any side effects on the rest of the system. Imagine tweet deck that is showing only liked tweets, or a list that is sorted by time of liking. This now means that you either have to replicate all of the logic on your server

..
Read 11 tweets
9 Jul 20
Lots of talk about React suspense today. I’m very excited about it.

However, I feel like the patterns I’ve seen in #ReactQuery (and friends like SWR) have alone been more transformative for my own dev process and users and have even prepped me for suspense in a lot of ways.
Of course, Suspense isn’t out yet, and the ecosystem will likely experience a smash of collective inovation around it when it comes out. That’s the exciting part. But what I feel like I’m starting to realize after playing around with it is that in the end,
The biggest thing that suspense is going to do for me is just one thing: avoiding that flash of loading/placeholder for newly mounted components. Suspense doesn’t fetch, it doesn’t codesplit, it doesn’t preload for you and it doesn’t cache for you.
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Thank you for your support!

Follow Us on Twitter!

:(