-
Notifications
You must be signed in to change notification settings - Fork 281
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
Remix v2 #1289
Remix v2 #1289
Conversation
This comment has been minimized.
This comment has been minimized.
@@ -59,7 +59,7 @@ export async function loader({params, request, context}: LoaderArgs) { | |||
} | |||
|
|||
if (!product.selectedVariant) { | |||
return redirectToFirstVariant({product, request}); | |||
throw redirectToFirstVariant({product, request}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes returned types work better, and I think it doesn't change the behavior, right?
export const useRootLoaderData = () => { | ||
const [root] = useMatches(); | ||
return root?.data as SerializeFrom<typeof loader>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding this small abstraction to enhance types. Thoughts?
} | ||
``` | ||
|
||
This way, you can import `useRootLoaderData()` anywhere in your app and get the correct type for the data returned by the root loader. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cool, I didn't know about it.
Co-authored-by: Bret Little <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with useRootLoaderData
I think we should note breaking change in changeset?
V2_MetaFunction
rename toMetaFunction
LoaderArgs
rename toLoaderFunctionArgs
I had links to the Remix release notes in the demo-store changeset but I've now added the same links to the other packages. Also added a couple of common examples 👍 |
FYI We'll release v2 support in our next major bump to avoid breaking changes for users in minor/patch releases.
This is just to track the required changes for supporting Remix v2.
I had to add a fewFixed!@ts-ignore
due to a bug in the types: remix-run/remix#7246Should be fixed for v2 stable I think.
Todos:
@ts-ignore
commentsNote: the preview environment in this PR shows the demo-store and it has unrelated errors due to the new CSP