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.

`List` skips child components that are indirectly composed of `List.Item`

See original GitHub issue

What package has an issue

@mantine/core

Describe the bug

function MyList() {
  return (
    <List>
      {
        ['a', 'b', 'c'].map((value, i) => (
          <MyListItem item={value} key={i} />
        )
      }
    </List>
  )
}

function MyListItem({ item }) {
  return (
    <List.Item>{item}</List.Item>
  )
}

The above code doesn’t render anything inside the List. However, it is expected to render List.Items

This is caused by filterChildByType function here: https://github.com/mantinedev/mantine/blob/a140cbca9dbf0f90b2314b25a64cc58413dacbc5/src/mantine-core/src/components/List/List.tsx#L68

In which browser did the problem occur

Firefox

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

Yes

Are you willing to participate in fixing this issue and create a pull request with the fix

Yes

Possible fix

A possible fix is to introduce a new prop named indirectItems or noFilterChildren that skips filtering children.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rtivitalcommented, Mar 12, 2022

Fixed in 4.0.2

1reaction
rtivitalcommented, May 17, 2022

Timeline.Item depends on its index, there is no way of getting this index during ssr, so it will remain as is (it will not be migrated to context as List.Item).

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Get all child elements - Stack Overflow
It is an expensive operation to get all direct/indirect children. ... Yes, you can use find_elements_by_ to retrieve children elements into a list....
Read more >
Descendant combinator - CSS: Cascading Style Sheets | MDN
Selectors that utilize a descendant combinator are called descendant selectors. /* List items that are descendants of the "my-things" list */ ul ...
Read more >
Warning: Each Child in a List Should Have a Unique 'key' Prop
When creating a list in the UI from an array with JSX, you should add a key prop to each child and to...
Read more >
3 levels of CSS-selectors to select all elements - Portiva.nl
This is how you can skip levels of explicit selectors to get to your target selector, through 'unique' landmarks within your template. Child...
Read more >
What is React Memo? How to use React.memo()
As for this new child component, it will simply be returning the <li> item with list title to display after mapping:
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