Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
react-table-hoc-fixed-columns
Advanced tools
Higher Order Components for ReactTable v6. It make possible to fixed one or more columns on the left and/or on the right. It use position: sticky
for recent browsers, and fallback for legacy browser.
Documentation of previous v1 here
-striped
and -highlight
className still working, even on fixed columnsnpm install react-table-hoc-fixed-columns --save
It's really simple: add fixed
property to your columns with value left
and right
import ReactTable from 'react-table';
import "react-table/react-table.css";
import withFixedColumns from 'react-table-hoc-fixed-columns';
import 'react-table-hoc-fixed-columns/lib/styles.css' // important: this line must be placed after react-table css import
const ReactTableFixedColumns = withFixedColumns(ReactTable);
...
render () {
return (
<ReactTableFixedColumns
data={data}
columns={[
{
Header: 'First Name',
accessor: 'firstName',
fixed: 'left',
},
{
Header: 'Last Name',
accessor: 'lastName',
fixed: 'left',
},
...
{
Header: 'age',
accessor: 'age',
fixed: 'right',
}
]}
/>
)
}
Fixed columns also work with groups.
Tips: if your table contain at least one header group, place yours fixed columns into a group too (even with an empty Header name)
import ReactTable from 'react-table';
import "react-table/react-table.css";
import withFixedColumns from 'react-table-hoc-fixed-columns';
import 'react-table-hoc-fixed-columns/lib/styles.css' // important: this line must be placed after react-table css import
const ReactTableFixedColumns = withFixedColumns(ReactTable);
...
render () {
return (
<ReactTableFixedColumns
data={data}
columns={[
{
Header: 'Group names',
fixed: 'left',
columns: [
{
Header: 'First Name',
accessor: 'firstName',
},
{
Header: 'Last Name',
accessor: 'lastName',
},
]
},
{
Header: 'Other group',
columns: [
...
]
}
]}
/>
)
}
There is some custom props that can be usefull
innerRef
- ref to the ReactTable component
render () {
return (
<ReactTableFixedColumns
innerRef={(ref) => { this.tableRef = ref; }}
/>
)
}
If the browser doesn't support position: sticky
, there is a fallback with transform: translate3d()
on each scroll event. The animation is not always smooth, it depend on your browser, OS, and scroll trigger (mouse wheel or scroll bar), but it works.
You can force to use only legacy browsers version:
import { withFixedColumnsScrollEvent } from 'react-table-hoc-fixed-columns'
import ReactTable from 'react-table';
const Table = withFixedColumnsScrollEvent(ReactTable);
or also force only sticky position version:
import { withFixedColumnsStickyPosition } from 'react-table-hoc-fixed-columns'
...
Check sticky support https://caniuse.com/#search=sticky
If your browser doesn't support ES7, please import es7-shim. Alternatively, you could just use the polyfill for the Array includes
method.
v0
to v1
For migration to v0.1.x
to v1.x.x
, fixed: true
is equivalent to fixed: left
, no need to change the value.
v1
to v2
v2 contain styles improvement. CSS-in-JS was removed, in order to let a full override style. However, you now must manually include css file
import "react-table/react-table.css";
...
import 'react-table-hoc-fixed-columns/lib/styles.css';
stripedColor
and highlightColor
props was remove. You can now override it with pure css.Follow these steps to get started developing :
git clone https://github.com/guillaumejasmin/react-table-hoc-fixed-columns.git
npm install
npm run lib:watch
- Transpile the src/lib
folder in watch modenpm run demo
- start a development server with the demo website based on the src/demo
folder.FAQs
ReactTable HOC for fixed columns
The npm package react-table-hoc-fixed-columns receives a total of 0 weekly downloads. As such, react-table-hoc-fixed-columns popularity was classified as not popular.
We found that react-table-hoc-fixed-columns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.