Search code examples
reactjsgriddle

Griddle v1 onRowClick not firing


Was tasked to upgrade from Griddle v0.7 to Griddle v1.1. But I can't seeme to get onRowClick to work.

import React, { Component } from 'react';
import Griddle from 'griddle-react';

export default class Table extends Component {
  render() {
    const data = [...something];

    return <Griddle
      data={data} 
      onRowClick={() => console.log("row clicked")} /> 
  }
}

If I look through the issues on github or other examples, this should work just fine.


Solution

  • The Griddle v1 way to solve this would be to define a RowEnhancer to provide an onClick, like this example:

      <Griddle
        components={{
          RowEnhancer: OriginalComponent =>
            props => (
              <OriginalComponent
                {...props}
                onClick={() => console.log(`Click Row ${props.griddleKey}`)}
                />
            ),
        }}
        ...
        />