update swr

This commit is contained in:
Aarni Halinen
2022-04-10 23:19:04 +03:00
parent cf77735c39
commit fa5e8b76c8
10 changed files with 27 additions and 32 deletions
+9 -14
View File
@@ -32,7 +32,7 @@
"sharp": "^0.30.1",
"shortid": "^2.2.16",
"styled-components": "^5.3.0",
"swr": "^0.5.6"
"swr": "^1.2.2"
},
"devDependencies": {
"@types/jest": "^27.0.1",
@@ -12581,14 +12581,11 @@
"dev": true
},
"node_modules/swr": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/swr/-/swr-0.5.7.tgz",
"integrity": "sha512-Jh1Efgu8nWZV9rU4VLUMzBzcwaZgi4znqbVXvAtUy/0JzSiN6bNjLaJK8vhY/Rtp7a83dosz5YuehfBNwC/ZoQ==",
"dependencies": {
"dequal": "2.0.2"
},
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/swr/-/swr-1.2.2.tgz",
"integrity": "sha512-ky0BskS/V47GpW8d6RU7CPsr6J8cr7mQD6+do5eky3bM0IyJaoi3vO8UhvrzJaObuTlGhPl2szodeB2dUd76Xw==",
"peerDependencies": {
"react": "^16.11.0 || ^17.0.0"
"react": "^16.11.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/symbol-tree": {
@@ -23939,12 +23936,10 @@
"dev": true
},
"swr": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/swr/-/swr-0.5.7.tgz",
"integrity": "sha512-Jh1Efgu8nWZV9rU4VLUMzBzcwaZgi4znqbVXvAtUy/0JzSiN6bNjLaJK8vhY/Rtp7a83dosz5YuehfBNwC/ZoQ==",
"requires": {
"dequal": "2.0.2"
}
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/swr/-/swr-1.2.2.tgz",
"integrity": "sha512-ky0BskS/V47GpW8d6RU7CPsr6J8cr7mQD6+do5eky3bM0IyJaoi3vO8UhvrzJaObuTlGhPl2szodeB2dUd76Xw==",
"requires": {}
},
"symbol-tree": {
"version": "3.2.4",
+1 -1
View File
@@ -86,6 +86,6 @@
"sharp": "^0.30.1",
"shortid": "^2.2.16",
"styled-components": "^5.3.0",
"swr": "^0.5.6"
"swr": "^1.2.2"
}
}
+3 -3
View File
@@ -28,13 +28,13 @@ const generateFetchParams = (id = "", options: Options = {}) => {
};
interface FetchArguments {
initialData?: Event | Event[],
fallbackData?: Event | Event[],
id?: string;
options?: Options
}
const useFetchEvents = ({
initialData,
fallbackData,
id = "",
options = {},
}: FetchArguments) => {
@@ -46,7 +46,7 @@ const useFetchEvents = ({
configRef.current = config;
}
const { data, error } = useSWR([url, configRef.current], fetcher, { initialData });
const { data, error } = useSWR([url, configRef.current], fetcher, { fallbackData });
return {
data: data?.results || data,
error,
+3 -3
View File
@@ -25,13 +25,13 @@ const generateFetchParams = (id = "", options: Options = {}) => {
};
interface FetchArguments {
initialData?: Post | Post[],
fallbackData?: Post | Post[],
id?: string;
options?: Options
}
const useFetchFeed = ({
initialData,
fallbackData,
id = "",
options = {},
}: FetchArguments) => {
@@ -43,7 +43,7 @@ const useFetchFeed = ({
configRef.current = config;
}
const { data, error } = useSWR([url, configRef.current], feedFetcher, { initialData });
const { data, error } = useSWR([url, configRef.current], feedFetcher, { fallbackData });
return {
data: data?.results || data,
error,
+3 -3
View File
@@ -28,13 +28,13 @@ const generateFetchParams = (id = "", options: Options = {}) => {
};
interface FetchArguments {
initialData?: JobAd | JobAd[],
fallbackData?: JobAd | JobAd[],
id?: string;
options?: Options;
}
const useFetchJobAds = ({
initialData,
fallbackData,
id = "",
options = {},
}: FetchArguments) => {
@@ -46,7 +46,7 @@ const useFetchJobAds = ({
configRef.current = config;
}
const { data, error } = useSWR([url, configRef.current], jobAdFetcher, { initialData });
const { data, error } = useSWR([url, configRef.current], jobAdFetcher, { fallbackData });
return {
data: data?.results || data,
error,
+2 -2
View File
@@ -24,8 +24,8 @@ interface InitialProps {
}
const InEnglishPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
const eventResult = useFetchEvents({ initialData: initialEvents, options: eventOptions });
const feedResult = useFetchFeed({ initialData: initialFeed, options: feedOptions });
const eventResult = useFetchEvents({ fallbackData: initialEvents, options: eventOptions });
const feedResult = useFetchFeed({ fallbackData: initialFeed, options: feedOptions });
return (
<>
+2 -2
View File
@@ -24,8 +24,8 @@ interface InitialProps {
}
const FrontPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
const eventResult = useFetchEvents({ initialData: initialEvents, options: eventOptions });
const feedResult = useFetchFeed({ initialData: initialFeed, options: feedOptions });
const eventResult = useFetchEvents({ fallbackData: initialEvents, options: eventOptions });
const feedResult = useFetchFeed({ fallbackData: initialFeed, options: feedOptions });
return (
<>
+2 -2
View File
@@ -16,8 +16,8 @@ interface InitialProps {
}
const ActualPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
const eventResult = useFetchEvents({ initialData: initialEvents });
const feedResult = useFetchFeed({ initialData: initialFeed });
const eventResult = useFetchEvents({ fallbackData: initialEvents });
const feedResult = useFetchFeed({ fallbackData: initialFeed });
return (
<>
+1 -1
View File
@@ -24,7 +24,7 @@ const SignUpPage: NextPage<InitialProps> = ({ initialForm }) => {
const router = useRouter();
const id = String(initialForm?.id ?? "");
const URL = `${FORM_URL}${id}/`;
const { data, error } = useSWR<SignupForm>(URL, (url) => axios.get(url).then((res) => res.data), { initialData: initialForm });
const { data, error } = useSWR<SignupForm>(URL, (url) => axios.get(url).then((res) => res.data), { fallbackData: initialForm });
if (error) {
console.error(error);
+1 -1
View File
@@ -13,7 +13,7 @@ interface InitialProps {
const CorporatePage: NextPage<InitialProps> = ({ initialJobAds }) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { data, error } = useFetchJobAds({ initialData: initialJobAds });
const { data, error } = useFetchJobAds({ fallbackData: initialJobAds });
return (
<>
<Head>