Hydrogen Perf Changes
There are a number of performance improvements we should make to improve the default performance of Hydrogen apps, including:
- [x] #1477
- [ ] #1478
- [ ] #1479
- [x] #1480
- [ ] #1481
FYI, tracking these changes here: @developit @surma
Just confirmed and reproduced this myself. The issue seems to be with the defer and json functions from @shopify/remix-oxygen.
It seems to think that the actual object is under data.data which is wrong.
Also confirming exact same issue.
You can repro the issue with the following:
npm create @shopify/hydrogen@latest- Paste this into a route:
import { useLoaderData } from '@remix-run/react';
import { defer } from '@shopify/remix-oxygen';
export const loader = async () => {
return defer({ test: "test" });
};
export default function Index() {
const data = useLoaderData<typeof loader>();
return (
<div>{data.test}</div>
)
}
- Observe type error:
Property 'test' does not exist on type 'JsonifyObject<Pick<DeferredData, "init"> & { data: { test: string; }; readonly [typedDeferredDataBrand]: "TypedDeferredData"; }>'.
I'm looking into this, and I think it's because @remix-run/server-runtime was not properly moved to be a peer dep of @shopify/remix-oxygen
This is now fixed with @shopify/remix-oxygen v2.0.1.
I apologize, but the fix also requires updating to @shopify/[email protected]