Skip to content

Commit

Permalink
Fix missing dentists on initial page load
Browse files Browse the repository at this point in the history
  • Loading branch information
rjackson committed Oct 6, 2023
1 parent ee1c4b9 commit 81bd906
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions contexts/Dentists.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ export function DentistsProvider({ initialLocation, initialRadius, children }) {

// Refetch dentists on change
const { lat: searchLat, lng: searchLng } = searchLocation;
const isFirstRun = useRef(true);
useEffect(() => {
let mounted = true;

if (mounted) {
// First run will be seeded by server. Skip it
if (isFirstRun.current) {
isFirstRun.current = false;
} else {
loadDentists(searchLat, searchLng, searchRadius).then((dentists) => setAllDentists(dentists));
loadManifest().then(({ resolutions }) => setResolutions(resolutions));
}
loadDentists(searchLat, searchLng, searchRadius).then((dentists) => setAllDentists(dentists));
loadManifest().then(({ resolutions }) => setResolutions(resolutions));
}

return () => {
Expand Down

0 comments on commit 81bd906

Please sign in to comment.