Merge pull request #5

Fix: cyclical structure in JSON object
This commit is contained in:
Dawid Wysokiński 2021-05-19 17:51:24 +02:00 committed by GitHub
commit 57e3dad53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -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 />