1

This problem might lay in React syntax that I do not understand well.

I have an array and I'm making Buttons with *array.maps((item) => * and I'm creating buttons as much as I have elements in the array. BUT I can not trigger/call any function with those buttons. I press those buttons but nothing happens. Any idea why?

in parent's class:

class ParentClass extends Component{
    constructor(props){ 
       super(props);
       this.state = { 
          someObjectXX: {
            someArrayZZ: ['first', 'next', 'anything']
          }
       }
    }

    render{ 
      return( 
        <ChildClass someObjectXX={this.state.someObjectXX} /> 
      ) 
    }
}

in child's class:

class ChildClass extends Component{
   sayGoodbye = () => {
         alert("scream if it works ^_^ ");
   }

   render{
     return (           
       <div>
          {this.props.someObjectXX.someArrayZZ.map((item) => {

              return (  
                <Row key={number} >
                   <Button text={shortName} handler={this.sayGoodbye} />
                </Row>
              )    

          })}
       </div>    
     )
   }
 }
Zack Zilic
  • 832
  • 3
  • 12
  • 28

1 Answers1

1

Hmm, that looks like it should work. Check the fiddle here and see if you're missing something:

https://fiddle.sencha.com/#view/editor&fiddle/2k5u

Make sure the keys on your Row components are unique.

meluskyc
  • 11
  • 1