Skip to content

Commit

Permalink
fix example application
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharpandey13 committed Jan 20, 2025
1 parent 6470629 commit c637fee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions examples/cra-react-router/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import { createRoot } from "react-dom/client";
import React, { PropsWithChildren } from 'react';
import App from './App.js';
import { Auth0Provider, AppState } from '@auth0/auth0-react';
import App from './App';
import { Auth0Provider, AppState, Auth0ContextInterface, User } from '@auth0/auth0-react';
import { BrowserRouter, useNavigate } from 'react-router-dom';
import { Auth0ProviderOptions } from '../../../src/index.js';

const Auth0ProviderWithRedirectCallback = ({
children,
context,
...props
}: PropsWithChildren<Auth0ProviderOptions>) => {
}: PropsWithChildren<Omit<Auth0ProviderOptions, 'context'>> & {
context?: React.Context<Auth0ContextInterface<User>>
}) => {
const navigate = useNavigate();

const onRedirectCallback = (appState?: AppState) => {
const onRedirectCallback = (appState?: AppState, user?: User) => {
navigate((appState?.returnTo) || window.location.pathname);
};

return (
<Auth0Provider onRedirectCallback={onRedirectCallback} {...props}>
<Auth0Provider
onRedirectCallback={onRedirectCallback}
context={context}
{...props}
>
{children}
</Auth0Provider>
);
};

const root = createRoot(document.getElementById('root')!);

root.render(
Expand Down
2 changes: 1 addition & 1 deletion examples/cra-react-router/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"isolatedModules": true,
Expand Down

0 comments on commit c637fee

Please sign in to comment.