Skip to content

Commit a19b02e

Browse files
Merge pull request #73 from ivanildobarauna-dev/codex/fix-high-priority-bugs-in-lazy-loading
fix: allow lazy sections to retry after load errors
2 parents f55a0f6 + c56b9bf commit a19b02e

File tree

3 files changed

+30
-18
lines changed

3 files changed

+30
-18
lines changed

frontend/src/components/LazyEducationSection.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export default function LazyEducationSection() {
3636
}, [certifications]);
3737

3838
const loadEducationData = useCallback(async () => {
39-
if (!loadedSections.education && !loading) {
40-
const wasSuccessful = await fetchEducation();
41-
if (wasSuccessful) {
42-
setSectionLoaded('education');
43-
setHasLoaded(true);
44-
}
39+
if (loadedSections.education || loading) {
40+
return loadedSections.education;
41+
}
42+
43+
const wasSuccessful = await fetchEducation();
44+
if (wasSuccessful) {
45+
setSectionLoaded('education');
46+
setHasLoaded(true);
4547
}
48+
49+
return wasSuccessful;
4650
}, [
4751
loadedSections.education,
4852
loading,

frontend/src/components/LazyExperienceSection.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ export default function LazyExperienceSection() {
2121
const [hasLoaded, setHasLoaded] = useState(false);
2222

2323
const loadExperienceData = useCallback(async () => {
24-
if (!loadedSections.experience && !loading) {
25-
const wasSuccessful = await fetchExperiences();
26-
if (wasSuccessful) {
27-
setSectionLoaded('experience');
28-
setHasLoaded(true);
29-
}
24+
if (loadedSections.experience || loading) {
25+
return loadedSections.experience;
3026
}
27+
28+
const wasSuccessful = await fetchExperiences();
29+
if (wasSuccessful) {
30+
setSectionLoaded('experience');
31+
setHasLoaded(true);
32+
}
33+
34+
return wasSuccessful;
3135
}, [
3236
loadedSections.experience,
3337
loading,

frontend/src/components/LazyProjectsSection.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ export default function LazyProjectsSection() {
2020
const [hasLoaded, setHasLoaded] = useState(false);
2121

2222
const loadProjectsData = useCallback(async () => {
23-
if (!loadedSections.projects && !loading) {
24-
const wasSuccessful = await fetchProjects();
25-
if (wasSuccessful) {
26-
setSectionLoaded('projects');
27-
setHasLoaded(true);
28-
}
23+
if (loadedSections.projects || loading) {
24+
return loadedSections.projects;
2925
}
26+
27+
const wasSuccessful = await fetchProjects();
28+
if (wasSuccessful) {
29+
setSectionLoaded('projects');
30+
setHasLoaded(true);
31+
}
32+
33+
return wasSuccessful;
3034
}, [
3135
loadedSections.projects,
3236
loading,

0 commit comments

Comments
 (0)