Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
extend Mantine Accordion Item

Mantine accordion specifies that its content should be only of type Accordion.Item (or, AccordionItem) - see the documentation for the children props. This means that even functions that actually return AccordionItem will not be listed.

So, this simple component will display only AccordionItem(s) that were instantiated inline, yet, not one returned from another function (see MyAccordionItem in this simple app).

The code:

import React, { Component } from 'react';
import { render } from 'react-dom';
import { Accordion } from '@mantine/core';

const MyAccordionItem = ({children, label}) =>
  <Accordion.Item label={label}>
    {children}
  </Accordion.Item>;

function App() {
  return (
    <div style={{width: 200}}>
      <div>pre</div>
      <Accordion>
        <Accordion.Item label="section0">
          <div>sec0.item1</div>
          <div>sec0.item2</div>
          <div>sec0.item3</div>
        </Accordion.Item>


        {/* Section 1 is not displayed because it is no of type Accordion.Item 
        <MyAccordionItem label="section 1">
          <div>sec1.item1</div>
          <div>sec1.item2</div>
          <div>sec1.item3</div>
        </MyAccordionItem>

        <Accordion.Item label="section2">
          <div>sec2.item1</div>
          <div>sec2.item2</div>
          <div>sec2.item3</div>
        </Accordion.Item>
      </Accordion>
      <div>post</div>
    </div>
  );
}

render(<App />, document.getElementById('root'));

The reason is the filter function defined here, and used by the accordion here.

My questions are:

  1. Do you know of any work around that helps assigning the same type (or, appearing to be an Accordion.Item when defining your own component?
  2. On a larger scale, What do you think is the right approach from the library's perspective (in this case mantine), i.e. should it suffice in checking that the returned type is An accordion item?
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I came across this same issue and found this GitHub issue in the Mantine repository with more information about creating child components that return AccordionItems.

rtivital (Mantine's creator) states:

Yes, currently that is not supported, it will require breaking changes, so Accordion and other similar components will be Migrated to context with next major release (5.0)

As to a work around, I haven't found anything yet other than creating a custom component for the content inside the AccordionItem and then wrapping that with the Mantine AccordionItem component inline via mapping or explicitly listing them.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!