Here is the codeblock:
const expandRow = {
    renderer: row => (
        <div>
            <BootstrapTable
                keyField='id'
                data={ row.data }
                columns={ columns1 }
            />
        </div>
    )
};
export default class MyPage extends Component {
    constructor(props, context) {
        super(props, context);
    }
    componentDidMount() {
        this.props.actions.fetchData().  // fetches in this.props.data
    }
    rowEvents = {
        onClick: (e, row, rowIndex) => {
            this.props.actions.fetchHistory(row.Id).   /* this is undefined */
        }
    }
    render() {
        return (
            <BootstrapTable
                keyField='Id'
                data={ this.props.data }
                columns={ columns }
                striped
                rowEvents={ this.rowEvents }
                expandRow={ expandRow }
            />
        )
    }
}
What I am trying to do is for each row clicked, I want to fetch data by triggering an action. I might be wrong about understanding the context of 'this' here. Any ideas?
rowEvents is not a function but a constant, try to define it with const
const rowEvents = {
        onClick: (e, row, rowIndex) => {
            this.props.actions.fetchHistory(row.Id).   /* this is undefined */
        }
    }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With