Skip to content

Commit

Permalink
update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharpandey13 committed Jan 16, 2025
1 parent 8bedf88 commit 49c550f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions examples/cra-react-router/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createRoot } from "react-dom/client";
import React, { PropsWithChildren } from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import App from './App.js';
import { Auth0Provider, AppState } from '@auth0/auth0-react';
import { BrowserRouter, useNavigate } from 'react-router-dom';
import { Auth0ProviderOptions } from '../../../src';
import { Auth0ProviderOptions } from '../../../src/index.js';

const Auth0ProviderWithRedirectCallback = ({
children,
Expand All @@ -12,7 +12,7 @@ const Auth0ProviderWithRedirectCallback = ({
const navigate = useNavigate();

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

return (
Expand All @@ -22,7 +22,9 @@ const Auth0ProviderWithRedirectCallback = ({
);
};

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

root.render(
<React.StrictMode>
<BrowserRouter>
<Auth0ProviderWithRedirectCallback
Expand All @@ -37,6 +39,5 @@ ReactDOM.render(
<App />
</Auth0ProviderWithRedirectCallback>
</BrowserRouter>
</React.StrictMode>,
document.getElementById('root')
</React.StrictMode>
);

0 comments on commit 49c550f

Please sign in to comment.