Skip to content

Instantly share code, notes, and snippets.

@iamparthaonline
Created July 14, 2025 05:29
Show Gist options
  • Select an option

  • Save iamparthaonline/ecdc104715ff16e3f0e42ef44b361a29 to your computer and use it in GitHub Desktop.

Select an option

Save iamparthaonline/ecdc104715ff16e3f0e42ef44b361a29 to your computer and use it in GitHub Desktop.
// utils.js
export async function getUserData() {
const res = await fetch('https://jsonplaceholder.typicode.com/users/1')
return res.json()
}
// UserComponent.jsx
import { use } from 'react'
import { getUserData } from './utils'
export default function UserComponent() {
const user = use(getUserData())
return (
<div>
<h1>{user.name}</h1>
<p>{user.email}</p>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment