Loading video...

Video Failed to Load

Go Home

📹So I got nerd-sniped into making a Trellix clone with TANSTACK React Query over the weekend. I think it works really well, but feel free to disagree. No framework, no backend - just the great msw, vite + RQ SPA. Nice side-effect: it works if you lose network connection 😱

149,175 views • 2 years ago •via X (Twitter)

10 Comments

Dominik 🔮's profile picture
Dominik 🔮2 years ago

Shout out to @ryanflorence for making a really polished demo. I struggled making the optimistic updates in the UI - lots of concurrent mutations are not easy to get right. So I defaulted to writing to the QueryCache. Bit more code, but works great.

Dominik 🔮's profile picture
Dominik 🔮2 years ago

I tried to take as much code as possible from the original implementation, so a lot of code should look familiar. One thing I couldn't get to work is the flush-sync-then-scroll approach Ryan did. It might have something to do with how useSyncExternalStore works, not sure.

Dominik 🔮's profile picture
Dominik 🔮2 years ago

Instead, I converted this to a more declarative callback-ref approach, where items scroll themselves into view when they mount. This works really well apart from needing forwardRef (can't wait for React 19 😂)

Dominik 🔮's profile picture
Dominik 🔮2 years ago

I also found some edge cases that don't work super well (maybe you do, too?) that we'd have to fix in Query internally, so that alone is totally worth the effort. I like how remix groups mutations together with a key and that could be something for us, too in the future.

Dominik 🔮's profile picture
Dominik 🔮2 years ago

Overall, I'm quite happy with the result. You can: - play with the demo: - look at the source: Let me know what you think.

Ryan Florence's profile picture
Ryan Florence2 years ago

@tan_stack Where's the code and deployment?

Dominik 🔮's profile picture
Dominik 🔮2 years ago

@tan_stack 3 tweets down

Samuel Cook's profile picture
Samuel Cook2 years ago

@tan_stack How many teasing “dude this thing sucks” retweets do you think you’ll get?

Dominik 🔮's profile picture
Dominik 🔮2 years ago

@tan_stack I'm happy with it and I learned a thing or two and I don't really care about the rest

freddie's profile picture
freddie2 years ago

@tan_stack the UX of SPAs is hard to beat, that feels smooth as butter

Related Videos