router icon indicating copy to clipboard operation
router copied to clipboard

Meta route options is gone?

Open ziggy6792 opened this issue 2 years ago • 11 comments

Describe the bug

Firstly, thanks a lot for an awesome tool! Have wanted this in react for ages!

In the alpha release ^0.0.1-alpha.0 we have a meta property on route options. I see in v1 that this is gone. But then the docs do still mention Dynamic meta tag management and I am wondering

  • Is meta tagging still available but moved?
  • Just removed?
  • Replaced with something else?

Below I show an example of how I was using meta options. Screenshot 2024-01-19 at 12 05 07 PM

Then type safety using this Screenshot 2024-01-19 at 12 06 30 PM

This was working well, but maybe theres is a different/better way to do this now?

Thanks :)

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

  • Install latest version of @tanstack/react-router ^1.6.0
  • Meta options is gone from RouteOptions

Expected behavior

Meta options still available on RouteOptions

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

N/A

ziggy6792 avatar Jan 19 '24 04:01 ziggy6792

I was also using this to generate the menu structure in my app, from the route tree. I haven't been able to find a way to get it working with RouteContext, as it seems like this isn't usable outside the <Outlet/>.

EDIT: This was also discussed here previously: https://github.com/TanStack/router/discussions/760

MrAdam avatar Jan 19 '24 07:01 MrAdam

cc @schiller-manuel

tannerlinsley avatar Jan 19 '24 16:01 tannerlinsley

You can now use the newly added staticData route option: https://tanstack.com/router/latest/docs/framework/react/guide/static-route-data

tannerlinsley avatar Jan 26 '24 06:01 tannerlinsley

Hey @tannerlinsley, would it be possible to enforce static data at a Route level?

For example, if I define a /_layout, that all /_layout/<children> must include that static data; while if there's another /_other-layout, such static data is not enforced.

mikededo avatar Jan 26 '24 06:01 mikededo

Possible, but it’ll take some work.

tannerlinsley avatar Jan 26 '24 07:01 tannerlinsley

Do you mean that it will take work to be added to the library? Not that I'm in a hurry for anything, I was just wondering.

mikededo avatar Jan 26 '24 07:01 mikededo

Correct!

tannerlinsley avatar Jan 26 '24 07:01 tannerlinsley

Hey @tannerlinsley thanks a lot for the response. Replaced meta with staticData everything seems to work fine :)

ziggy6792 avatar Jan 26 '24 09:01 ziggy6792

And better yet, it’s available right in the match!

tannerlinsley avatar Jan 26 '24 20:01 tannerlinsley

@tannerlinsley I can open a new issue if you'd like, but is it intentional that the types don't support doing this with lazy routes? If I ignore the type errors, it works just fine.

Pateriack avatar Jun 11 '24 19:06 Pateriack

You need to create both routes, a lazy one and non-lazy one. Put staticData into the non-lazy one. see also https://tanstack.com/router/latest/docs/framework/react/guide/code-splitting#how-does-tanstack-router-split-code

schiller-manuel avatar Jun 11 '24 20:06 schiller-manuel