Загрузка видео...

Не удалось загрузить видео

На главную

React Server Actions have helped me: ◆ Write less code ◆ Build better user experiences How can we create products that are resilient to slower internet connections and instantly provide feedback on user input? ↓

77,482 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 11

Фото профиля Surjith S M ✪
Surjith S M ✪2 лет назад

What if the user closed the tab thinking they made the vote but in reality the request is still pending?

Фото профиля Lee Robinson
Lee Robinson2 лет назад

This seems to work: useEffect(() => { function handler(e) { if (!state.pending) return; e.preventDefault(); } window.addEventListener('beforeunload', handler); return () => { window.removeEventListener('beforeunload', handler); }; }, [state.pending]); Where `state.pending` comes from `useOptimistic` state.

Фото профиля Wonderchat
Wonderchat2 лет назад

Automate up to 70% of your customer support today. Save time and help your users find answers quickly. Try now at

Фото профиля ⟁ndrew V
⟁ndrew V2 лет назад

curious about error handling, if the optimistic+server actions, end up conflicting with db data. I get it that the likelihood is .0001 low of the conflict in this example, but say in a scenario where 100 users are up and down voting... what could my risk of mutant mutations be?

Фото профиля Lee Robinson
Lee Robinson2 лет назад

Since I'm using Redis here, you could use transactions to make sure every upvote was counted when 100 folks modify the same item. There wouldn't be conflicts on inserts since each has a new UUID. Does that answer your question?

Фото профиля Jonny Summers-Muir
Jonny Summers-Muir2 лет назад

Love this @leeerob - I think this was where I tripped up a bit in the NextJS docs. There isn’t a huge amount of information on using forms in a client context (useFormState etc) vs a RSC context. It’s like the ServerActions guide and forms in nextjs guide need squashing together.

Фото профиля Lee Robinson
Lee Robinson2 лет назад

Good news, we recently updated these docs and combined them!

Фото профиля Jay
Jay2 лет назад

What are you using to generate those subtitles and the animation?

Фото профиля Faizan Arif
Faizan Arif2 лет назад

What about error handling? Let’s say some API failed in server actions, what is the optimistic and standard way to handle all those errors on client side?

Фото профиля Lee Robinson
Lee Robinson2 лет назад

I cover error handling a bit here with `useFormStatus`

Фото профиля hardcoded
hardcoded2 лет назад

This is great!

Похожие видео

We are super pleased to share the 11th PA to the #Flux ecosystem, Coinbase 🛡️ Base! Flux-Base will provide some fantastic opportunities for us in a new and developing ecosystem. Here are a few items that will deliver interchain operability: Bridging Flux blockchain to Base Build, Coinbase's Layer 2 solution, offers several massive advantages: 1. **Access to a Wider User Base**: Coinbase has a large and established user base. By bridging with Base, flux can tap into this user pool, gaining exposure and adoption among a broader audience. 2. **EVM Compatibility**: Base is EVM-compatible, meaning it can seamlessly interact with #Ethereum-based assets and services. This compatibility allows for easier integration and interoperability between Flux and the Base ecosystem. 3. Innovation and Dapp Development: Base's environment is conducive to decentralized application (dApp) development. Bridging with Base opens up opportunities for developers on your blockchain to innovate and create dApps that can leverage Flux and Base's capabilities. 4. Seamless Integration with Coinbase Products: Base offers seamless integration with various Coinbase products. This integration can provide Flux access to advanced tools and services offered by Coinbase, enhancing the overall functionality and user experience. 5. Increased Liquidity: Bridging with Base can increase the liquidity of Flux, providing additional avenues for trading and exchange within the Coinbase ecosystem. So, bridging with Base can provide scalability, cost-efficiency, security, and access to a broader ecosystem that will be highly beneficial for the growth and adoption of Flux. Learn more here: #web3 #blockchain #CloudComputing #DePIN

Flux I Decentralized Cloud

148,498 просмотров • 2 лет назад