{"id":22051887,"url":"https://github.com/ohansemmanuel/react_suspense_concurrent_app","last_synced_at":"2025-03-23T15:27:53.048Z","repository":{"id":98263419,"uuid":"287907362","full_name":"ohansemmanuel/react_suspense_concurrent_app","owner":"ohansemmanuel","description":"render-as-you-fetch example application","archived":false,"fork":false,"pushed_at":"2020-09-28T13:01:43.000Z","size":406,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T22:52:28.756Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohansemmanuel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-16T08:52:25.000Z","updated_at":"2020-12-17T06:06:38.000Z","dependencies_parsed_at":"2023-03-09T01:15:54.156Z","dependency_job_id":null,"html_url":"https://github.com/ohansemmanuel/react_suspense_concurrent_app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Freact_suspense_concurrent_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Freact_suspense_concurrent_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Freact_suspense_concurrent_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Freact_suspense_concurrent_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohansemmanuel","download_url":"https://codeload.github.com/ohansemmanuel/react_suspense_concurrent_app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245121919,"owners_count":20564207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T15:11:57.497Z","updated_at":"2025-03-23T15:27:53.039Z","avatar_url":"https://github.com/ohansemmanuel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Render as you fetch\n\n![https://i.imgur.com/0y5iDgE.gif](https://i.imgur.com/0y5iDgE.gif)\n\nRender-as-you-fetch simply refers to not blocking the UI rendering while fetching data. In traditional approaches, we did this:\n\n1. Start fetching data\n2. Finish fetching data\n3. Start rendering UI\n\nWith suspense we can do the following:\n\n1. Start fetching\n2. **Start rendering**\n3. **Finish fetching**\n\nEssentially, you start rendering pretty much immediately after kicking off the network request.\n\n[See docs](https://reactjs.org/docs/concurrent-mode-suspense.html#approach-3-render-as-you-fetch-using-suspense)\n\n\u003cbr /\u003e\n\n## Goal\n\nThe goal here is to take a sample project and implement the render as you fetch pattern. Sounds simple? Don't get cocky yet, huh? 😉\n\nRead on!\n\n\u003cbr /\u003e\n\n## Running the starter application\n\n\u003cbr /\u003e\n\n1️⃣ **Clone the repository**\n\n```bash\ngit clone https://github.com/ohansemmanuel/react_suspense_concurrent_app.git\n```\n\n2️⃣ **Install dependencies**\n\n```bash\nnpx yarn\n```\n\n3️⃣ **Start the app**\n\n```bash\nnpx yarn start\n```\n\n\u003cbr /\u003e\n\nPoint your browser to `http://localhost:3000/`. You should see the following:\n\n\u003cbr /\u003e\n\n![https://i.imgur.com/4cSn98f.png](https://i.imgur.com/4cSn98f.png)\n\n\u003cbr /\u003e\n\n4️⃣ **View the UI components**\n\nTo make the challenge focused on logic, UI components have been built for you. To view them, run:\n\n```bash\nnpx yarn start:dev\n```\n\nPoint your browser to `http://localhost:6060/`. You should have a React [Styleguidist](https://react-styleguidist.js.org/) server running. Inspect the components and live editable code.\n\n\u003cbr /\u003e\n\n## App requirement\n\nYou will make an API call to fetch a list of users, then fetch their profile details and have these all rendered.\n\nSee the full requirement below:\n\nYour UI should start with a bare card (or UI section) to hold the result of the initial data fetch i.e the user names. Use the `Card` component provided.\n\n![https://i.imgur.com/UqyonQD.png](https://i.imgur.com/UqyonQD.png)\n\nWhile waiting for the fetched result, have a loading indicator displayed:\n\n![https://i.imgur.com/7aun6Mq.png](https://i.imgur.com/7aun6Mq.png)\n\nOnce the API request is successful, you'll get a list of user names and their IDs. Render the user names.\n\n![https://i.imgur.com/n5MzCT8.png](https://i.imgur.com/n5MzCT8.png)\n\nImmediately after getting the list of user names, begin fetching their corresponding user details (different API requests). The initial network request was a single one. This includes multiple requests for each user.\n\n![https://i.imgur.com/4sutKDE.png](https://i.imgur.com/4sutKDE.png)\n\nWhile fetching the user details, make sure clicking a user name works, while also rendering a loading indicator.\n\n![https://i.imgur.com/dLYaAxz.png](https://i.imgur.com/dLYaAxz.png)\n\nMake sure the user details requests are parallelized i.e isn't waiting for the other to be completed first\n![https://i.imgur.com/eHwhm9e.png](https://i.imgur.com/eHwhm9e.png)\n\nMake sure the UI is incrementally updated for each user detail request\n\n![https://i.imgur.com/4vYuFfm.png](https://i.imgur.com/4vYuFfm.png)\n\n\u003cbr /\u003e\n\nHere's what a working solution looks like:\n\n![https://i.imgur.com/P9YVQqJ.gif](https://i.imgur.com/P9YVQqJ.gif)\n\n\u003cbr /\u003e\n\n## Chief Requirement\n\nArguably the most important requirement here is to make sure **start rendering immediately after kicking off the network request**. You know you're on the wrong path if you do this:\n\n```jsx\n// fetchDetails is fired after initial render :(\nuseEffect(() =\u003e fetchDetails(), []);\n```\n\nYou'd want to use a suspense library for this one. e.g. Recoil or Relay.\n\n## API requests/Server details\n\nSee the `/api` directory for api query functions `getUserNames` and `getUserDetails`. These point to the `/users` and `/users/${userId}` respectively.\n\nFor this to work, you need to run the accompanying [server](https://github.com/ohansemmanuel/react_suspense_concurrent_app_server) to which these requests are proxied.\n\nClone the repo:\n\n```bash\ngit clone https://github.com/ohansemmanuel/react_suspense_concurrent_app_server.git\n```\n\nInstall dependencies:\n\n```bash\nnpx yarn\n```\n\nand start the server:\n\n```bash\nnpx yarn start\n```\n\nvisit http://localhost:3001/\n\n\u003cbr /\u003e\n\n## Endpoints\n\n| route         |           resource            |\n| ------------- | :---------------------------: |\n| /             |     default user details      |\n| /users        | list of user names (with IDs) |\n| /users/\\${id} |     specific user details     |\n\n## Challenge Solution\n\n- See branch 'recoil' for recoil solution\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohansemmanuel%2Freact_suspense_concurrent_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohansemmanuel%2Freact_suspense_concurrent_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohansemmanuel%2Freact_suspense_concurrent_app/lists"}