Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from neynarxyz/ds/fix-gh-action-build-errors
Browse files Browse the repository at this point in the history
fix: handle null props for `getKey` and add `hls.js` & `swr` to `devDependencies` for the build
  • Loading branch information
dylsteck authored Jul 15, 2024
2 parents 82bef41 + 3b2c9fe commit 63609d4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 6 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
]
},
"peerDependencies": {
"hls.js": "^1.5.13",
"@pigment-css/react": "^0.0.9",
"hls.js": "^1.5.13",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"swr": "^2.2.5"
Expand All @@ -47,7 +47,9 @@
"axios": "^1.6.8",
"dotenv": "^16.4.5",
"eslint-plugin-storybook": "^0.8.0",
"hls.js": "^1.5.13",
"storybook": "^8.1.11",
"swr": "^2.2.5",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vite-plugin-dts": "^3.9.0",
Expand Down
11 changes: 9 additions & 2 deletions src/components/organisms/NeynarFeedList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export type NeynarFeedListProps = {
clientId?: string;
};

type PreviousPageData = {
casts: any[];
next: {
cursor: string;
};
};

function formatCasts(casts: any[]): CastCardProps[] {
return casts.map((cast: any) => {
return {
Expand All @@ -44,7 +51,7 @@ function formatCasts(casts: any[]): CastCardProps[] {

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

const getKey = (pageIndex: number, previousPageData: any, props: NeynarFeedListProps & { clientId: string }) => {
const getKey = (pageIndex: number, previousPageData: PreviousPageData | null, props: NeynarFeedListProps & { clientId: string }) => {
if (previousPageData && !previousPageData.casts.length) return null;

let requestUrl = `${NEYNAR_API_URL}/v2/farcaster/feed?feed_type=${props.feedType}&client_id=${props.clientId}`;
Expand All @@ -68,7 +75,7 @@ export const NeynarFeedList: React.FC<NeynarFeedListProps> = (props) => {
const [isFetchingNextPage, setIsFetchingNextPage] = useState(false);

const { data, error, size, setSize, isValidating } = useSWRInfinite(
(pageIndex, previousPageData) => getKey(pageIndex, previousPageData, { ...props, clientId: client_id }),
(pageIndex: number, previousPageData: PreviousPageData | null) => getKey(pageIndex, previousPageData, { ...props, clientId: client_id }),
fetcher
);

Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3560,6 +3560,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@~2.3.2, fsevents@~2.3.3:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"
Expand Down

0 comments on commit 63609d4

Please sign in to comment.