Skip to content

Commit 49c550f

Browse files
update example code
1 parent 8bedf88 commit 49c550f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/cra-react-router/src/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { createRoot } from "react-dom/client";
12
import React, { PropsWithChildren } from 'react';
2-
import ReactDOM from 'react-dom';
3-
import App from './App';
3+
import App from './App.js';
44
import { Auth0Provider, AppState } from '@auth0/auth0-react';
55
import { BrowserRouter, useNavigate } from 'react-router-dom';
6-
import { Auth0ProviderOptions } from '../../../src';
6+
import { Auth0ProviderOptions } from '../../../src/index.js';
77

88
const Auth0ProviderWithRedirectCallback = ({
99
children,
@@ -12,7 +12,7 @@ const Auth0ProviderWithRedirectCallback = ({
1212
const navigate = useNavigate();
1313

1414
const onRedirectCallback = (appState?: AppState) => {
15-
navigate((appState && appState.returnTo) || window.location.pathname);
15+
navigate((appState?.returnTo) || window.location.pathname);
1616
};
1717

1818
return (
@@ -22,7 +22,9 @@ const Auth0ProviderWithRedirectCallback = ({
2222
);
2323
};
2424

25-
ReactDOM.render(
25+
const root = createRoot(document.getElementById('root')!);
26+
27+
root.render(
2628
<React.StrictMode>
2729
<BrowserRouter>
2830
<Auth0ProviderWithRedirectCallback
@@ -37,6 +39,5 @@ ReactDOM.render(
3739
<App />
3840
</Auth0ProviderWithRedirectCallback>
3941
</BrowserRouter>
40-
</React.StrictMode>,
41-
document.getElementById('root')
42+
</React.StrictMode>
4243
);

0 commit comments

Comments
 (0)