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

🗺 API updates for v2 meta arguments and types #5785

Merged
merged 8 commits into from
Mar 14, 2023
Merged

Conversation

chaance
Copy link
Collaborator

@chaance chaance commented Mar 13, 2023

This PR does a few things we'll want to include behind the v2_meta flag before the major release.

  • V2_HtmlMetaDescriptor has been renamed to V2_MetaDescriptor. This is shorter but also more aligned with the links function return value type, which is LinkDescriptor. It also makes a bit more sense as we support values for other HTML tags than <meta>.
  • V2_HtmlMetaDescriptor and V2_HtmlMetaFunction types should be imported from @remix-run/react instead of @remix-run/<runtime> since A) the primary responsibility of meta is rendering, and B) matches data only makes sense in the context of an app calling useMatches. I think we should follow suit here with LinksFunction in v2, but that's for a separate PR.
  • The meta function's arguments have been simplified
    • parentsData has been removed, as each route's loader data is available on the data property of its respective match object
      // before
      export function meta({ parentsData }) {
        return {
          title: parentsData['routes/some-route'].title,
        };
      };
      // after
      export function meta({ matches }) {
        return {
          title: matches.find((match) => match.id === 'routes/some-route').data.title,
        };
      };
    • The route property on route matches has been removed, as relevant match data is attached directly to the match object
      // before
      export function meta({ parentsData }) {
        let rootModule = matches.find(match => match.route.id === "root");
      };
      // after
      export function meta({ matches }) {
        let rootModule = matches.find(match => match.id === "root");
      };

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2023

⚠️ No Changeset found

Latest commit: f7945c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 18 packages
Name Type
@remix-run/cloudflare Minor
@remix-run/deno Minor
@remix-run/node Minor
@remix-run/react Minor
@remix-run/server-runtime Minor
@remix-run/cloudflare-pages Minor
@remix-run/cloudflare-workers Minor
@remix-run/architect Minor
@remix-run/express Minor
@remix-run/netlify Minor
@remix-run/testing Minor
@remix-run/vercel Minor
@remix-run/dev Minor
@remix-run/serve Minor
create-remix Minor
@remix-run/css-bundle Minor
remix Minor
@remix-run/eslint-config Minor

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Member

@ryanflorence ryanflorence left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some questions, nothing blocking though.

docs/route/meta.md Outdated Show resolved Hide resolved
packages/remix-react/components.tsx Show resolved Hide resolved
packages/remix-react/components.tsx Show resolved Hide resolved
@chaance chaance merged commit a33ebfb into dev Mar 14, 2023
@chaance chaance deleted the chance/v2-meta-fixes branch March 14, 2023 21:51
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Mar 14, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-2072f33-20230315 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

fernandojbf pushed a commit to fernandojbf/remix that referenced this pull request Mar 21, 2023
@MichaelDeBoey MichaelDeBoey changed the title API updates for v2 meta arguments and types 🗺 API updates for v2 meta arguments and types Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants