mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-06 12:57:44 +00:00
docs: write intro to article
This commit is contained in:
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 120 KiB |
@@ -12,8 +12,46 @@
|
|||||||
}
|
}
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Thus far in our article series, we've taken a look at how React handles reactivity, server rendering, and how to send data back and forth between our React-based server and our client.
|
||||||
|
|
||||||
|
In particular, our last article outlined how we can send data from the server down to the client and back:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This is a great _almost_ bi-directional communication.
|
||||||
|
|
||||||
|
> Why do you say "almost"? What's missing?
|
||||||
|
|
||||||
|
Well, once you send an action back to the server, how do you get a response back from the server? What happens if the server action needs to inform you of some status?
|
||||||
|
|
||||||
|
Well, this is where `useFormStatus` and `useFormState` come into play:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# What is `useFormStatus`?
|
# What is `useFormStatus`?
|
||||||
|
|
||||||
|
`useFormStatus` allows developers to listen for state changes on their React Server Actions. IE: When a server action is pending or not.
|
||||||
|
|
||||||
|
While `useFormStatus` isn't directly a way to listen for changes from the server (instead it relies on the information on the client to show its metadata) it allows us to make a nicer user experience by showing a loading indicator while the server is taking its action.
|
||||||
|
|
||||||
|
------------------------------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- It works on the client
|
- It works on the client
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
|||||||
Reference in New Issue
Block a user