Skip to content

Commit

Permalink
fix: import useSWRInfinite hook from 'frappe-react-sdk'
Browse files Browse the repository at this point in the history
  • Loading branch information
yjane99 committed Apr 12, 2024
1 parent 45b0a6b commit 9c8bd49
Show file tree
Hide file tree
Showing 3 changed files with 286 additions and 293 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { TENOR_API_KEY, TENOR_CLIENT_KEY, TENOR_FEATURED_API_ENDPOINT_BASE } from "./GIFPicker"
import { GIFGallerySkeleton } from "./GIFGallerySkeleton"
import useSWRInfinite from "swr/infinite";
import { useMemo } from "react";
import { Button } from "@radix-ui/themes";
import { useSWRInfinite } from "frappe-react-sdk";


export interface Props {
onSelect: (gif: Result) => void
}

// const fetcher = (url: string) => fetch(url).then(res => res.json())

const fetcher = async (url: string) => {
const response = await fetch(url);
const data = await response.json();
Expand All @@ -19,8 +17,6 @@ const fetcher = async (url: string) => {

export const GIFFeaturedResults = ({ onSelect }: Props) => {

// const { data: GIFS, isLoading } = useSWR<TenorResultObject>(`${TENOR_FEATURED_API_ENDPOINT_BASE}?&key=${TENOR_API_KEY}&client_key=${TENOR_CLIENT_KEY}`, fetcher)

const { data, size, setSize, isLoading } = useSWRInfinite(
(index: any, previousPageData: any) => {
// reached the end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import useSWRInfinite from "swr/infinite";
import { TENOR_API_KEY, TENOR_CLIENT_KEY, TENOR_SEARCH_API_ENDPOINT_BASE } from "./GIFPicker"
import { GIFGallerySkeleton } from "./GIFGallerySkeleton"
import { useMemo } from "react";
import { Button } from "@radix-ui/themes";
import { useSWRInfinite } from "frappe-react-sdk";

export interface Props {
query: string
onSelect: (gif: Result) => void
}

// const fetcher = (url: string) => fetch(url).then(res => res.json())

const fetcher = async (url: string) => {
const response = await fetch(url);
const data = await response.json();
Expand All @@ -19,8 +17,6 @@ const fetcher = async (url: string) => {

export const GIFSearchResults = ({ query, onSelect }: Props) => {

// const { data: GIFS, isLoading } = useSWR<TenorResultObject>(`${TENOR_SEARCH_API_ENDPOINT_BASE}?q=${query}&key=${TENOR_API_KEY}&client_key=${TENOR_CLIENT_KEY}&limit=10`, fetcher)

const { data, size, setSize, isLoading } = useSWRInfinite(
(index: any, previousPageData: any) => {
// reached the end
Expand Down
Loading

0 comments on commit 9c8bd49

Please sign in to comment.