Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): client-side data fetching loading state (vercel#53164)
setLoading must be "true" at first and then set to "false". The documentation, as is, always has the value of setLoading set to "false". The purpose of this code is to show "...loading" on the screen while the data is being fetched. In order for this to happen, setLoading must be initially set to "true" and then (after the data is successfully loaded) set to "false", since the line `if (isLoading) return <p>Loading...</p>` is asking if the content is still loading, and if it is, it'll return a message indicating it. Because of this ### What? setLoading should be set to "true" at first. ### Why? Because the code then asks if the content is being loaded. The code (as is) always has setLoading set as "false" and it doesn't show the loading message when it's supposed to. ### How? I changed the line to `const [isLoading, setLoading] = useState(true)`. Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
- Loading branch information