4 ms·
The blog post is an easier read: https://react.dev/blog/2024/12/05/react-19 https://react.dev/blog/2024/12/05/react-19
by cyral 2y ago
The blog post is an easier read: https://react.dev/blog/2024/12/05/react-19 https://react.dev/blog/2024/12/05/react-19
- nailer 2y agoconst error = await updateName(newName); Why would updateName return an error? Why not just throw an Error like JS/TS?
- Mogzol 2y agoIt's just an example async call, it could be anything. It's not the important part of that code example, it's only purpose is to show that an async call is happening. It could be written as a try/catch, or it could be written how they wrote it. I guess they chose that way because it's short and to the point.
- nailer 2y agoGood example code is otherwise uninteresting apart from the concept that is meant to be shown.
- BillSaysThis 2y agoupdateName is a call to the backend/server to update the database...
- rtpg 2y agoSome guesses: - People really like Result structures - People who wrote the API believe in the "operational issues and business issues should not be comingled" philosophy (so this function might raise on a connection error, but it _won't_ raise when there's simply an error like a name conflict) - People who wrote the example write Too Much(TM) Go