Skip to content

Commit

Permalink
move to subscribe function
Browse files Browse the repository at this point in the history
  • Loading branch information
Flirre committed Jan 25, 2024
1 parent 480239b commit 85435c0
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions examples/04_react_router/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ import history from './routerHistory';

const Route1 = <h1>Hello</h1>;
const Route2 = <h1>World</h1>;
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) => {

Check failure on line 15 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

'arg' is defined but never used
const callback = (callbackArg) => {
const searchParams = new URLSearchParams(callbackArg.location.search);
const loc = { searchParams, ...callbackArg.location };

Check failure on line 18 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

'loc' is assigned a value but never used
//set(loc); // how do I set the atom from in here?

Check failure on line 19 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

Expected exception block, space or tab after '//' in comment
};
const unlisten = history.listen((listenArg) => {});

Check failure on line 21 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

'listenArg' is defined but never used
callback(history);
return unlisten;
},
});

const App = () => {
const loc = useAtomValue(location);
Expand All @@ -34,7 +35,7 @@ const App = () => {
flexDirection: 'column',
gap: '16px',
}}
>
>
{/* @ts-expect-error */}

Check failure on line 39 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer
<UNSTABLE_HistoryRouter history={history}>

Check failure on line 40 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

Imported JSX component UNSTABLE_HistoryRouter must be in PascalCase or SCREAMING_SNAKE_CASE

Check failure on line 40 in examples/04_react_router/src/App.tsx

View workflow job for this annotation

GitHub Actions / test

Identifier 'UNSTABLE_HistoryRouter' is not in camel case
current pathname in atomWithLocation: &quot;{loc.pathname}&quot;
Expand Down

0 comments on commit 85435c0

Please sign in to comment.