diff --git a/examples/04_react_router/src/App.tsx b/examples/04_react_router/src/App.tsx
index 9057dc5..4afdc8f 100644
--- a/examples/04_react_router/src/App.tsx
+++ b/examples/04_react_router/src/App.tsx
@@ -11,17 +11,18 @@ import history from './routerHistory';
const Route1 =
Hello
;
const Route2 = World
;
-const location = atomWithLocation();
-location.onMount = (set) => {
- const callback = (arg) => {
- const searchParams = new URLSearchParams(arg.location.search);
- const loc = { searchParams, ...arg.location };
- set(loc);
- };
- const unlisten = history.listen(callback);
- callback(history);
- return unlisten;
-};
+const location = atomWithLocation({
+ subscribe: (arg) => {
+ const callback = (callbackArg) => {
+ const searchParams = new URLSearchParams(callbackArg.location.search);
+ const loc = { searchParams, ...callbackArg.location };
+ //set(loc); // how do I set the atom from in here?
+ };
+ const unlisten = history.listen((listenArg) => {});
+ callback(history);
+ return unlisten;
+ },
+});
const App = () => {
const loc = useAtomValue(location);
@@ -34,7 +35,7 @@ const App = () => {
flexDirection: 'column',
gap: '16px',
}}
- >
+ >
{/* @ts-expect-error */}
current pathname in atomWithLocation: "{loc.pathname}"