Skip to content

Commit

Permalink
fix(another authentiction fix): fix useeffect referencing wrong variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rileylnapier committed Feb 8, 2024
1 parent 38d2276 commit 6e8bd1a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/react-inbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ import { CourierProvider } from "@trycourier/react-provider";
import { Inbox } from "@trycourier/react-inbox";

function App() {
const [authentication, setAuthentication] = useState();
const [authorization, setAuthorization] = useState();

useEffect(() => {
const response = await fetchAuthToken();
setAuthentication(response);
setAuthentication(response.token);
}, []);

return (
<CourierProvider userId={yourUserId} authentication={authentication}>
<CourierProvider userId={yourUserId} authorization={authorization}>
<Inbox />
</CourierProvider>
);
Expand All @@ -263,22 +263,22 @@ import { CourierProvider } from "@trycourier/react-provider";
import { Inbox } from "@trycourier/react-inbox";

function App() {
const [authentication, setAuthentication] = useState();
const [authorization, setAuthorization] = useState();

useEffect(() => {
const response = await fetchAuthToken();
setAuthentication(response);
setAuthorization(response.token);

const interval = setInterval(async () => {
const response = await fetchAuthToken();
setAuthentication(response);
setAuthorization(response.token);
}, 300000);

return () => clearInterval(interval);
}, []);

return (
<CourierProvider userId={yourUserId} authentication={YOUR_CLIENT_KEY}>
<CourierProvider authorization={authorization}>
<Inbox />
</CourierProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-provider/src/hooks/use-courier-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const useCourierActions = (state, dispatch) => {
};
}, [
state.apiUrl,
state.authentication,
state.authorization,
state.clientKey,
state.userId,
state.userSignature,
Expand Down
1 change: 1 addition & 0 deletions packages/storybook/stories/inbox/2.0.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CourierProvider } from "@trycourier/react-provider";
import { Inbox } from "@trycourier/react-inbox";

import mockMiddleware from "./mock-middleware";
import { Authentication } from "../getting-started/index.stories";

const API_URL = process.env.API_URL || "";
const INBOX_API_URL = process.env.INBOX_API_URL || "";
Expand Down

0 comments on commit 6e8bd1a

Please sign in to comment.