npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-table-factory

v0.2.13

Published

React table factory HoC with a set of wrapper HoCs

Readme

react-table-factory

A set of table factory decorators to easily implement table components inside user projects.

Demo

table HoC

A HoC to implement table components with a set of overridable options.

| option | default | description | | --- | --- | --- | | rowRenderer | DefaultRowRenderer | table row component | | cellRenderer | DefaultCellRenderer | table tbody cell component | | dataRowRenderer | DefaultDataRowRenderer | table tbody row implementation | | dataCellRenderer | DefaultDataCellRenderer | wrapper around tbody cell content | | headerCellRenderer | DefaultHeaderCellRenderer | table thead cell component | | headerCellContentRenderer | DefaultHeaderCellRenderer | wrapper around thead cell content| | headerRenderer | DefaultHeaderRenderer | table thead component | | columns | [] | array of column configurations. |

columns config

| name | type | description | | --- | --- | -- | | cell (optional) | Component {data, index, rowIndex, table props that are not used for HoC implementation} | Component to render a table cell | | header (optional) | Component {table props that are not used for HoC implementation} | Component to render a header cell | | name (optional) | string | Column key |

Simple example:

import { table } from 'react-table-factory';

...
const Table = table();

const columns = [
	{
		name: "attr1"
	},
	{
		header: (props) => "Attr custom component",
		cell: ({data, ...props}) => (
			<span>Custom output {data["attr2"]}</span>
		)
	},
];
...

const MyComponent = ({data, ...props}) => (
	<Table
		data={data}
		columns={columns}
		{...props} // props that will be propagated to cells.
	/>
)

Decorators

A set of decorators around table factory.

Some components can use css. Corresponding files should have the same base name. (i.e withFixedHeader.css).

| name (css) (remarks) | options(=defaults) | Table props:column config | description | | --- | --- | --- | --- | | withFixedHeader (true) ||| Creates 2 Tables to implement a fixed header and a scrollable table content. Since it creates 2 tables, any decorators with context wrappers around table should NOT be wrapped by this component. | | withInlineDetailsContext (false) | {selectionReducer, tabIndex, clearOnDataChange, isSelectable, keyFactory} | {detailsRenderer, clearOnDataChange}:{} | Wraps Table with selectionContext. Implemented selectionReducers are singeSelectionReducer and multiSelectionReducer. | | withClickableRowContext (false) | {tabIndex, isClickable} | {onRowClick}:{} | Wraps Table with ClickableRowContext. Provides capabilities for row clicking. | | withLazyLoading (false) | {Loading = ()=>'Loading', threshold=50, NoDataComponent} | {fetch, fetching=false, fetchable=true}:{} | Decorator around withFixedHeader table decorator. When fetching prop is set to true, show Loading component after table contents. If fetch != null, fetching=false, fetchable=true and the container is scrolled to bottom (taking threshold into account) fetch is called once. | | withSortingContext (true) | {defaultDirection, sortFactory, inMemory = false, sortableContextHoc} | {onSort, sortDirection='asc', sortParameter}:{sortable,name} | Wraps Table with SortableContext. Provides a Sorter Component to implement custom sorting elements. If a name option of column config is an array, the one from Table props will be used, otherwise the first elem will be used. | | withInMemorySortingContext (true) | {defaultDirection, sortFactory} | { onSort, defaultSortParameter, defaultSortDirection= 'asc'}:{sortable,name} | An overload wrapper for withSortingContext to provide in-memory sorting. | withAdaptive (true) (will change) | {Component} | {}:{removeAdaptiveColname, hideAdaptive, hideFullSize} | Injects a Component inside each cell. Adaptive layout should be handled using CSS rules. | | withHeaderControl (false) (will change) || {}:{control} | Adds 1 to colspan of each cell previous to column with controll. This component is used when you want to create an element in header, but doesn't effect the tbody cell layout. | | withHeaderCellOverflow (true) || {}:{removeOverflowWrapper} | Adds a set of wrapper around header cell contents. Overflow should be handled using css. | | withEmptyRow (false) | {isEmpty = (rowProps)=>false, Component, classNameFactory = (dataRowProps)=>'empty-row'}:{} || Provides capabilities to implement empty td that spans the whole row |

TODO

  • [ ] Add ColGroup Component.
  • [ ] Add tbody renderer option to table hoc.
  • [ ] Create decorator to add virtualization to withFixedHeader.
  • [ ] Remove withHeaderControl for a more flexible decorator.
  • [ ] Create user guide to create new decorators and use existing.
  • [ ] Use react router for more usage examples.