0

I have two Array of Objects given below

Head: [ 
        {name: "abc", Number: "931", TypeCode: "73HB"},
        {name: "pbc", Number: "781", TypeCode: "89PH"}
      ];
Super: [ 
        {name: "hxc", Number: "123", TypeCode: "T78"},
        {name: "bbc", Number: "567", TypeCode: "09Y"},
        {name: "TUJ", Number: "091", TypeCode: "OWE"}
      ];

   <Slider>
   {
      Head.map((item) => (
        <div>
          <h1>{item.name}</h1>
          <h1>{item.Number}</h1>
          <h1>{item.TypeCode}</h1>
        </div>
      )
      )
    }
   </Slider>

  <Slider>
   {
      Super.map((item) => (
        <div>
          <h1>{item.name}</h1>
          <h1>{item.Number}</h1>
          <h1>{item.TypeCode}</h1>
        </div>
      )
      )
    }
   </Slider>

   <div>
    <button  onClick={this.clickHandler()}   />
   </div>

   this.clickHandler(TypeCode, TypeCode) {

    console.log(TypeCode, TypeCode)

   }

How to pass the Head arrary typecode and super arrary type code in single shot with onClick button.

Note: The button is out side of the both mappers. I am using react-slick carousel for this. Thanks advance.

kirankumar
  • 135
  • 1
  • 7

1 Answers1

0

Not exactly sure what you're looking for but if you just want to get an array of all the typecode in both Head and Super you can do this:

const typeCodes = Head.concat(Super).map(item =>  item.TypeCode )
Paul Ryan
  • 461
  • 2
  • 6
  • thank you so much ,but i need based on active slide index. like TypeCode: "73HB" & TypeCode: "T78" is active in the react slick carousel i need those two only. – kirankumar Mar 28 '20 at 06:19