question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested component definitions via Item Link returns only IDs

See original GitHub issue

I’m not entirely sure if this is a bug or if this is as expected, but it seems like when I try to link objects beyond a certain level, only the IDs are returned.

In my case, I’m trying to link the following: Hero -> Card -> Stats

Hero is connected to the Card component via type: CommonFieldTypes.ItemLink, Card is connected to Stats via type: CommonFieldTypes.ContentList, and Stats are just objects with text fields.

Using this set up, I get the following returned in the api:

image

If I take the card definition out of the equation and link Hero directly with stats via type: CommonFieldTypes.ContentList, I get what I would expect: image

Note I left card in there so we can see the difference.

Is there a limitation to using ItemLink, or is it a mistake on my end? Note that this is in disconnected mode. Here is a gist of some of the relevant code: https://gist.github.com/sowhatdoido/c1115c7adc5cc9efc0c7c1ee6b586a97

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sc-dawidrutkowskicommented, Aug 12, 2019

@bouncehead13 Fix for this issue is merged. I’m closing this one.

1reaction
sowhatdoidocommented, Sep 21, 2018

@kamsar. If you flip the usage array so that it resolves from the bottom up, it will resolve the references in the children before cloning to the parent. You can fix it in one of two ways:

In expandReferencedContent.js in the sitecore-jss-manifest package, you can reverse the array before traversing it

- idMap.usages.forEach(function (idReference) {
+ idMap.usages.reverse().forEach(function (idReference) {
        expandedItems = true;
        var source = idMap.ids.get(idReference.id);

It would be more performant if you guys updated createIdMapping.js to use unshift instead of push, which will result in a reversed array during creation.

I don’t know if there are any unforeseen side effects for this change as we don’t have access to any tests, but making that change in my local node_modules seemed to have resolved the problem:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Guide to Nested Routes with React Router - ui.dev
In this comprehensive, up-to-date guide, you'll learn everything you need to know about creating nested routes with React Router.
Read more >
Get the url param from nested component - angular
the nested component will render on the router-outlet element and in it you coulde use ActivatedRoute and fetch the id param.
Read more >
React Router 6: Nested Routes - Robin Wieruch
In this function component we have matching Link and Route components from React Router for the home/ and user/ routes.
Read more >
Links in HTML documents - W3C
The A element. Syntax of anchor names; Nested links are illegal; Anchors with the id attribute; Unavailable and unidentifiable resources.
Read more >
How to implement nested routes with React Router
The <Link> component renders an anchor tag that navigates to different a route defined in the application. There is also <NavLink> you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found