I have a table which contains another table in reactjs. I've inserted a button inside each row of the outer table and when I clicked this I trigger an action for showing the nested table. My code is like this:
{slipsList.map((slip, i) =>
<tbody>
<tr key={i}>
<td className="table-sticky--first-col">
{slip.confirmationDate}
<button
type="button"
onClick={() => hideButtonClicked()}
>{i}</button>
</td>
<td>
{slip.slipNumber}
</td>
<td>
{slip.country}
</td>
<td>
{slip.side}
</td>
<td>
{slip.grossAmount}
</td>
<td>
{slip.commission}
</td>
<td>
{slip.feesPerStampDuty}
</td>
<td>
{slip.tax}
</td>
<td>
{slip.netAmount}
</td>
<td>
{slip.netAmountEuro}
</td>
</tr>
<tr
className={classnames({ hide_element: slipsHide })}
>
<td colSpan="10">
{renderInside(slip)}
</td>
</tr>
</tbody>
)}
When a user clicks the button in a row this row must collapse. My problem is that with my implementation when I click the button all the rows of the table are collapsed. My renderInside function is the following:
<tbody>
<tr>
<td>
{renderInstrumentInfo(slip.prodType,
slip.symbol, slip.exchange,
slip.country, slip.name)}
</td>
<td>{slip.type}</td>
<td>{slip.quantity}</td>
<td>{slip.price}</td>
<td>{slip.amount}</td>
</tr>
</tbody>
Any ideas?
slipsHidein this line,className={classnames({ hide_element: slipsHide })}. Can you show ur constructor ?