diff --git a/superglue/lib/components/Navigation.tsx b/superglue/lib/components/Navigation.tsx index 14f65412..ee249517 100644 --- a/superglue/lib/components/Navigation.tsx +++ b/superglue/lib/components/Navigation.tsx @@ -15,7 +15,7 @@ import { NavigationProviderProps, AllPages, SuperglueState, - PageKey + PageKey, } from '../types' import { Update } from 'history' import { useDispatch, useSelector, useStore } from 'react-redux' @@ -49,8 +49,10 @@ const NavigationProvider = forwardRef(function NavigationProvider( ref: ForwardedRef<{ navigateTo: NavigateTo }> ) { const dispatch = useDispatch() - const pages = useSelector((state) => state.pages) - const superglue = useSelector((state) => state.superglue) + const pages = useSelector((state) => state.pages) + const superglue = useSelector( + (state) => state.superglue + ) const store = useStore() useEffect(() => { @@ -74,12 +76,12 @@ const NavigationProvider = forwardRef(function NavigationProvider( // and so we have restore scroll and the set the active page // - In cases where the response was redirected, the calculated // navigationAction is set to 'replace', and is handled gracefully by navigateTo, - // before this method gets called. + // before this method gets called. // That's why we're only concerned with the first case, but we gracefully warn // if the application visit did not return the meta object like the dev was supposed to. return visit(pageKey, { revisit: true }).then((meta) => { if (meta) { - if (meta.navigationAction === "none") { + if (meta.navigationAction === 'none') { dispatch(setActivePage({ pageKey })) setWindowScroll(posX, posY) } @@ -139,10 +141,9 @@ const NavigationProvider = forwardRef(function NavigationProvider( const navigateTo: NavigateTo = ( path, { action } = { - action: 'push' + action: 'push', } ) => { - if (action === 'none') { return false } @@ -219,7 +220,7 @@ const NavigationProvider = forwardRef(function NavigationProvider( - + ) } else { diff --git a/superglue/lib/index.tsx b/superglue/lib/index.tsx index 53d3d06c..7773de89 100644 --- a/superglue/lib/index.tsx +++ b/superglue/lib/index.tsx @@ -29,7 +29,7 @@ import { ApplicationProps, NavigateTo, SuperglueStore, - SetupProps + SetupProps, } from './types' export { superglueReducer, pageReducer, rootReducer } from './reducers' export { getIn } from './utils/immutability' @@ -83,8 +83,8 @@ export const setup = ({ store, buildVisitAndRemote, history, - navigatorRef -} : SetupProps) => { + navigatorRef, +}: SetupProps) => { config.baseUrl = baseUrl const { visit, remote } = buildVisitAndRemote(navigatorRef, store) diff --git a/superglue/spec/features/navigation.spec.jsx b/superglue/spec/features/navigation.spec.jsx index 1252026e..c747ccab 100644 --- a/superglue/spec/features/navigation.spec.jsx +++ b/superglue/spec/features/navigation.spec.jsx @@ -36,7 +36,7 @@ const Home = () => { } const About = () => { - const {heading} = useContent() + const { heading } = useContent() return

About Page, {heading}

} @@ -200,7 +200,7 @@ describe('navigation', () => { navigateTo('/about#title') }) } - + return (

Home Page

@@ -337,13 +337,13 @@ describe('navigation', () => { } const Home = () => { - const { visit, navigateTo} = useContext(NavigationContext) + const { visit, navigateTo } = useContext(NavigationContext) const handleClick = () => { visit('/about').then(() => { navigateTo('/about', { action: 'replace' }) }) } - + return (

Home Page

@@ -402,9 +402,9 @@ describe('navigation', () => { const Home = () => { const { navigateTo } = useContext(NavigationContext) const handleClick = () => { - navigateTo('/home', {action: 'replace'}) + navigateTo('/home', { action: 'replace' }) } - + return (

Home Page

@@ -536,8 +536,8 @@ describe('navigation', () => { const Home = () => { useEffect(() => { process.nextTick(() => history.back()) - },[]) - + }, []) + return (

Home Page

@@ -631,7 +631,7 @@ describe('navigation', () => { const handleClick = () => { remote('/about?props_at=address') } - + return (

Home Page

diff --git a/superglue/spec/lib/NavComponent.spec.jsx b/superglue/spec/lib/NavComponent.spec.jsx index fcaf8313..f500d956 100644 --- a/superglue/spec/lib/NavComponent.spec.jsx +++ b/superglue/spec/lib/NavComponent.spec.jsx @@ -71,7 +71,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: "/home" + currentPageKey: '/home', }, }) @@ -108,7 +108,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) @@ -153,7 +153,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) const scrollTo = vi.spyOn(window, 'scrollTo').mockImplementation(() => {}) @@ -215,7 +215,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) @@ -235,7 +235,7 @@ describe('Nav', () => { } mountTimes++ }, []) - + return (

Home Page

@@ -243,7 +243,7 @@ describe('Nav', () => {
) } - + const About = () => { useEffect(() => { visitedAbout = true @@ -284,7 +284,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) @@ -336,7 +336,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/about' + currentPageKey: '/about', }, }) const scrollTo = vi @@ -385,7 +385,7 @@ describe('Nav', () => { posX: 10, posY: 10, }) - + const store = buildStore({ pages: { '/home': { @@ -399,7 +399,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/about' + currentPageKey: '/about', }, }) const scrollTo = vi @@ -465,7 +465,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) const scrollTo = vi @@ -520,7 +520,7 @@ describe('Nav', () => { }, superglue: { csrfToken: 'abc', - currentPageKey: '/home' + currentPageKey: '/home', }, }) const scrollTo = vi