user7805277
user7805277

Reputation:

debugged the code I think it will be this function onSelect

class Accordion extends React.Component {
  constructor(props) {
    super(props);

Upvotes: 2

Views: 68

Answers (1)

Michael Lyons
Michael Lyons

Reputation: 584

I've created a working solution here: JSFiddle

It seems that React.cloneElement prepends a modifier onto the props that are assigned. So instead of having a prop "_onSelect", it is being prepended by "$Accordion"

A working function call on those props looks like this:

this.props.$Accordion_onSelect(this.props.id);    

To remove the $Accordion addition, don't start the prop key with an underscore. If it's just 'onSelect' then it will be passed as 'onSelect'. Here's the JSFIddle

Upvotes: 1

Related Questions