fix: cyclical structure in JSON object that was caused by onReset={refetch}
This commit is contained in:
parent
fece52fe8c
commit
39fc5dbe7b
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useCallback, useMemo } from 'react';
|
||||||
import { polishPlurals } from 'polish-plurals';
|
import { polishPlurals } from 'polish-plurals';
|
||||||
import { NetworkStatus, useQuery } from '@apollo/client';
|
import { NetworkStatus, useQuery } from '@apollo/client';
|
||||||
import { RouteProp } from '@react-navigation/native';
|
import { RouteProp } from '@react-navigation/native';
|
||||||
|
@ -39,6 +39,12 @@ const TestScreen = ({ route }: TestScreenProps) => {
|
||||||
},
|
},
|
||||||
notifyOnNetworkStatusChange: true,
|
notifyOnNetworkStatusChange: true,
|
||||||
});
|
});
|
||||||
|
const handleReset = useCallback(() => {
|
||||||
|
refetch(undefined);
|
||||||
|
}, [refetch]);
|
||||||
|
const suggestions = useMemo(() => data?.similarQualifications.items ?? [], [
|
||||||
|
data,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
@ -59,12 +65,10 @@ const TestScreen = ({ route }: TestScreenProps) => {
|
||||||
<Test
|
<Test
|
||||||
qualification={data.qualification}
|
qualification={data.qualification}
|
||||||
questions={data.generateTest}
|
questions={data.generateTest}
|
||||||
onReset={refetch}
|
onReset={handleReset}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Suggestions
|
<Suggestions qualifications={suggestions} />
|
||||||
qualifications={data?.similarQualifications.items ?? []}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<QualificationNotFound />
|
<QualificationNotFound />
|
||||||
|
|
Reference in New Issue