Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add ignore as recommended by React docs (#16385)

兰天游fa985e901210
diff --git a/apps/docs/pages/guides/getting-started/tutorials/with-react.mdx b/apps/docs/pages/guides/getting-started/tutorials/with-react.mdx
index 2f111d71984..8ba8307b8fd 100644
--- a/apps/docs/pages/guides/getting-started/tutorials/with-react.mdx
+++ b/apps/docs/pages/guides/getting-started/tutorials/with-react.mdx
@@ -137,6 +137,7 @@ export default function Account({ session }) {
const [avatar_url, setAvatarUrl] = useState(null)
useEffect(() => {
+ let ignore = false
async function getProfile() {
setLoading(true)
const { user } = session
@@ -147,18 +148,24 @@ export default function Account({ session }) {
.eq('id', user.id)
.single()
- if (error) {
- console.warn(error)
- } else if (data) {
- setUsername(data.username)
- setWebsite(data.website)
- setAvatarUrl(data.avatar_url)
+ if (!ignore) {
+ if (error) {
+ console.warn(error)
+ } else if (data) {
+ setUsername(data.username)
+ setWebsite(data.website)
+ setAvatarUrl(data.avatar_url)
+ }
}
setLoading(false)
}
getProfile()
+
+ return () => {
+ ignore = true
+ }
}, [session])
async function updateProfile(event, avatarUrl) {