Created
July 14, 2025 05:29
-
-
Save iamparthaonline/ecdc104715ff16e3f0e42ef44b361a29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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