{"id":51691503,"url":"https://github.com/devjubayr/react_lazy_load","last_synced_at":"2026-07-16T02:34:31.883Z","repository":{"id":318325432,"uuid":"1070771709","full_name":"devjubayr/react_lazy_load","owner":"devjubayr","description":"Implementing react lazy load, utilizing component to render if the UI need this. With suspense","archived":false,"fork":false,"pushed_at":"2025-10-06T13:30:51.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-16T02:34:27.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devjubayr.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-06T12:20:53.000Z","updated_at":"2025-10-24T09:25:26.000Z","dependencies_parsed_at":"2025-10-06T15:25:34.092Z","dependency_job_id":"2a2cc7a5-d7c0-4e76-ab3a-2ed0eb150b47","html_url":"https://github.com/devjubayr/react_lazy_load","commit_stats":null,"previous_names":["crosbow/react_lazy_load","devjubayr/react_lazy_load"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devjubayr/react_lazy_load","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devjubayr%2Freact_lazy_load","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devjubayr%2Freact_lazy_load/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devjubayr%2Freact_lazy_load/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devjubayr%2Freact_lazy_load/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devjubayr","download_url":"https://codeload.github.com/devjubayr/react_lazy_load/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devjubayr%2Freact_lazy_load/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35528482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-16T02:00:06.687Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-07-16T02:34:27.071Z","updated_at":"2026-07-16T02:34:31.878Z","avatar_url":"https://github.com/devjubayr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 💤 React Lazy Load (Main Component Explanation)\n\nIn this example, **lazy loading** is implemented in the main `App.jsx` file using `React.lazy()` and `Suspense`.\n\n### 📘 `App.jsx` Explanation\n\n```jsx\nimport { Suspense, useState } from \"react\";\nimport { importFile } from \"./utils/importFile\";\n\nconst components = [\n  { path: \"todos\", btnLabel: \"Todos\" },\n  { path: \"posts\", btnLabel: \"Posts\" },\n];\n\nfunction App() {\n  const [component, setComponent] = useState(null);\n\n  const selectComp = async (path) =\u003e {\n    const Comp = await importFile(path); // dynamically imports the component\n    setComponent(\u003cComp /\u003e); // sets the component to render\n  };\n\n  return (\n    \u003cdiv className=\"p-5\"\u003e\n      \u003cnav className=\"space-x-3\"\u003e\n        {components.map((comp) =\u003e (\n          \u003cbutton\n            key={comp.path}\n            onClick={() =\u003e selectComp(comp.path)}\n            className=\"bg-gray-600 p-2 rounded-sm\"\n          \u003e\n            {comp.btnLabel}\n          \u003c/button\u003e\n        ))}\n      \u003c/nav\u003e\n\n      {/* Suspense shows fallback while component is being loaded */}\n      \u003cSuspense fallback={\u003ch2\u003eLoading...\u003c/h2\u003e}\u003e{component}\u003c/Suspense\u003e\n    \u003c/div\u003e\n  );\n}\n\nexport default App;\n```\n\n```jsx\nimport React from \"react\";\n\nexport const importFile = (file) =\u003e {\n  return React.lazy(() =\u003e import(`../components/${file}`)); // returns a promise\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevjubayr%2Freact_lazy_load","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevjubayr%2Freact_lazy_load","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevjubayr%2Freact_lazy_load/lists"}