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

Update React experimental version #758

Merged
merged 18 commits into from
Mar 18, 2022
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
12 changes: 12 additions & 0 deletions .changeset/happy-coins-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@shopify/hydrogen': patch
'create-hydrogen-app': patch
---

Upgrade to React experimental version `0.0.0-experimental-2bf7c02f0-20220314`.

To upgrade your Hydrogen app, change the pinned version of `react` and `react-dom` in your `package.json` file to this version, or run:

```bash
yarn add @shopify/hydrogen react@0.0.0-experimental-2bf7c02f0-20220314 react-dom@0.0.0-experimental-2bf7c02f0-20220314
```
4 changes: 2 additions & 2 deletions examples/template-hydrogen-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"body-parser": "^1.19.1",
"compression": "^1.7.4",
"graphql-tag": "^2.12.4",
"react": "0.0.0-experimental-529dc3ce8-20220124",
"react-dom": "0.0.0-experimental-529dc3ce8-20220124",
"react": "0.0.0-experimental-2bf7c02f0-20220314",
"react-dom": "0.0.0-experimental-2bf7c02f0-20220314",
"serve-static": "^1.14.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function Layout({children, hero}) {
<main role="main" id="mainContent" className="relative bg-gray-50">
{hero}
<div className="mx-auto max-w-7xl p-4 md:py-5 md:px-8">
{children}
<Suspense fallback={null}>{children}</Suspense>
</div>
</main>
<Footer collection={collections[0]} product={products[0]} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Suspense} from 'react';
import {Image, Link} from '@shopify/hydrogen';

import MoneyCompareAtPrice from './MoneyCompareAtPrice.client';
Expand Down Expand Up @@ -40,9 +41,13 @@ export default function ProductCard({product}) {

<div className="flex ">
{selectedVariant.compareAtPriceV2 && (
<MoneyCompareAtPrice money={selectedVariant.compareAtPriceV2} />
<Suspense fallback={null}>
<MoneyCompareAtPrice money={selectedVariant.compareAtPriceV2} />
</Suspense>
)}
<MoneyPrice money={selectedVariant.priceV2} />
<Suspense fallback={null}>
<MoneyPrice money={selectedVariant.priceV2} />
</Suspense>
</div>
</Link>
</div>
Expand Down
5 changes: 4 additions & 1 deletion jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import './scripts/polyfillWebRuntime';

globalThis.IS_REACT_ACT_ENVIRONMENT = true;

globalThis.scrollTo = () => null;

jest.mock('react-dom', () => {
const reactDom = jest.requireActual('react-dom');
const reactDomClient = jest.requireActual('react-dom/client');

return {
...reactDom,
render: (app, container) => {
// @ts-ignore
const root = reactDom.createRoot(container);
const root = reactDomClient.createRoot(container);
container.__unmount = root.unmount.bind(root);
root.render(app);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/preview/tests/preview.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {withCli} from '../../../testing';

describe('preview', () => {
describe.skip('preview', () => {
it('provides a helpful message when no worker build exists', async () => {
await withCli(async ({run, fs}) => {
const result = await run('preview');
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
"peerDependencies": {
"body-parser": "^1.19.1",
"compression": "^1.7.4",
"react": "0.0.0-experimental-529dc3ce8-20220124",
"react-dom": "0.0.0-experimental-529dc3ce8-20220124",
"react": "0.0.0-experimental-2bf7c02f0-20220314",
"react-dom": "0.0.0-experimental-2bf7c02f0-20220314",
"serve-static": "^1.14.1",
"vite": "^2.8.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/hydrogen/src/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
type ElementType,
} from 'react';
// @ts-expect-error hydrateRoot isn't on the TS types yet, but we're using React 18 so it exists
import {hydrateRoot} from 'react-dom';
import {hydrateRoot} from 'react-dom/client';
import type {ClientHandler} from './types';
import {ErrorBoundary} from 'react-error-boundary';
import {useServerResponse} from './framework/Hydration/rsc';
Expand Down
Loading