Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: should not use switch outside a router #168

Merged
merged 4 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/create-hydrogen-app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
- Wrap instances of `<Money>` in client components due to render prop usage
- Eliminate use of `Link` client re-exports
- fix: gallery safari grid layout
- fix: Move `LocalizationProvider` to `Layout.server` to prevent issues with React Router & Suspense

## 0.6.1 - 2021-11-08

Expand Down
28 changes: 11 additions & 17 deletions packages/dev/src/App.server.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ShopifyServerProvider,
DefaultRoutes,
LocalizationProvider,
} from '@shopify/hydrogen';
import {ShopifyServerProvider, DefaultRoutes} from '@shopify/hydrogen';
import {Switch} from 'react-router-dom';
import {Suspense} from 'react';

Expand All @@ -19,18 +15,16 @@ export default function App({...serverState}) {
return (
<Suspense fallback={<LoadingFallback />}>
<ShopifyServerProvider shopifyConfig={shopifyConfig} {...serverState}>
<LocalizationProvider>
<CartProvider>
<DefaultSeo />
<Switch>
<DefaultRoutes
pages={pages}
serverState={serverState}
fallback={<NotFound />}
/>
</Switch>
</CartProvider>
</LocalizationProvider>
<CartProvider>
<DefaultSeo />
<Switch>
<DefaultRoutes
pages={pages}
serverState={serverState}
fallback={<NotFound />}
/>
</Switch>
</CartProvider>
</ShopifyServerProvider>
</Suspense>
);
Expand Down
11 changes: 8 additions & 3 deletions packages/dev/src/components/Layout.server.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import {useShopQuery, flattenConnection, Image} from '@shopify/hydrogen';
import {
Image,
useShopQuery,
flattenConnection,
LocalizationProvider,
} from '@shopify/hydrogen';
import gql from 'graphql-tag';

import Header from './Header.client';
Expand All @@ -23,7 +28,7 @@ export default function Layout({children, hero}) {
const storeName = data ? data.shop.name : '';

return (
<>
<LocalizationProvider>
<div className="absolute top-0 left-0">
<a
href="#mainContent"
Expand Down Expand Up @@ -52,7 +57,7 @@ export default function Layout({children, hero}) {
</main>
<Footer collection={collections[0]} product={products[0]} />
</div>
</>
</LocalizationProvider>
);
}

Expand Down