I am using React Bootstrap table 2 for displaying data from external API. As part of my table i have included a dummy column which stores a button for every row when clicked should navigate to a different component with some row information.
The column definition in my code:
{
dataField: 'expand',
text: 'EXPAND',
isDummyField:true,
editable: false,
formatter: (cell, row, rowIndex, formatExtraData) =>
{
return (
<button
type="button"
onClick = {() => <ExtendedView data={row} /> }
>
<img src = {expand} alt="expand"></img>
</button>
);
},
headerStyle: () =>
{
return { width: '50px', textAlign: 'center' };
}
}
The Component to which button click should redirect:
import React from 'react';
class ExtendedView extends React.Component
{
constructor(props)
{
super(props)
this.state =
{
Id:0
}
}
render()
{
console.log(this.props.data)
console.log(this.state.Id)
return(
<div>
<h1>{this.props.data}</h1>
</div>
);
}
}
export default ExtendedView;
I am not getting any error neither am able to navigate to child component. Also nothing is getting printed as part of two console.log() command I am not sure what's actually going on with react or i have missed something.
This maybe a very simple catch but being a newbie in react i am not able to debug.
Please help.
Thanks...