mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-19 16:30:21 +00:00
This change allows you to technically use React Table without a layout hook. Under that assumption, you would need to come up with your own styling mechanisms for display. The useSimpleLayout merely adds a single `width` style to the prop getters for column headers and cells. The useFlexLayout is much more robust. Personally though, I have moved away from both, and am just using raw `display: table-row/table-cell` styles to let my tables display naturally.
29 lines
604 B
JavaScript
29 lines
604 B
JavaScript
export const useSimpleLayout = props => {
|
|
const {
|
|
hooks: { columns: columnsHooks, getHeaderProps, getCellProps }
|
|
} = props
|
|
|
|
columnsHooks.push(columns => {
|
|
getHeaderProps.push(column => ({
|
|
style: {
|
|
boxSizing: 'border-box',
|
|
width: column.width !== undefined ? `${column.width}px` : 'auto'
|
|
}
|
|
}))
|
|
|
|
getCellProps.push(cell => {
|
|
return {
|
|
style: {
|
|
boxSizing: 'border-box',
|
|
width:
|
|
cell.column.width !== undefined ? `${cell.column.width}px` : 'auto'
|
|
}
|
|
}
|
|
})
|
|
|
|
return columns
|
|
})
|
|
|
|
return props
|
|
}
|