Skip to content

Commit

Permalink
feat: load fid from url
Browse files Browse the repository at this point in the history
  • Loading branch information
stephancill committed Jun 15, 2024
1 parent dfa5155 commit b5e010f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/context/configContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ReactNode } from "react";
import { createContext, useContext, useState } from "react";
import { createContext, useContext, useEffect, useState } from "react";

export type ConfigContextType = {
fid: number | null;
Expand All @@ -20,6 +20,17 @@ export function ConfigContextProvider({
process.env.NEXT_PUBLIC_HUB_REST_URL || "https://nemes.farcaster.xyz:2281"
);

useEffect(() => {
console.log(window.location);
try {
const queryParameters = new URLSearchParams(window.location.search);
const fid = queryParameters.get("fid");
if (fid) {
setFid(parseInt(fid));
}
} catch (error) {}
}, [window.location]);

const value: ConfigContextType = {
fid,
setFid,
Expand Down

0 comments on commit b5e010f

Please sign in to comment.