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

@postadress/react-simple-table

v1.0.167

Published

## Intention

Readme

React Simple Table

Intention

The table should be as easy as possible to use.

Installation

yarn

yarn add @postadress/react-simple-table

npm

npm install @postadress/react-simple-table

Usage

React Simple Table uses the location for storing filter strings. Therefore it mus be used inside a Router component.

A basic example:

import React, { FC } from 'react';
import { SimpleTable } from '@postadress/react-simple-table';
import { Field } from '@postadress/react-simple-table/dist/table';

export const Component: FC = () => {
  const fields: Field[] = [
    {
      name: 'ID',
      identifier: 'id',
      width: 10,
    },
    {
      name: 'First Name',
      identifier: 'firstName',
    },
    {
      name: 'Last Name',
      identifier: 'lastName',
    },
    {
      name: 'Age',
      identifier: 'age',
      type: 'number'
    },
  ];

  const data = [
    {
        id: 1,
        firstName: 'Johnny',
        lastName: 'Lawrence',
        age: 50,
    },
    {
        id: 2,
        firstName: 'Daniel',
        lastName: 'LaRusso',
        age: 50,
    },
    {
        id: 3,
        firstName: 'Miguel',
        lastName: 'Diaz',
        age: 17,
    },
    {
        id: 4,
        firstName: 'Samantha',
        lastName: 'LaRusso',
        age: 17,
    }
  ];

  return (<SimpleTable fields={fields} data={data} />);
};

The above example will lead to a table like this:

React Simple Table example

Api

Field

Interface for column definitions.

| Property | Type | Optional | Default | Purpose | Example | |----------------|---------------------------------|----------|---------|-------------------------------------------------------------------------------------------|--------------------------------------------| | name | string | no | | This is the name of the column and therefore it is shown in the header row. | name: 'First name' | | identifier | string | no | | Technical identifier for the column. The name must not be unique, the identifier must. | identifier: 'firstName' | | width | number | yes | | The with of the column in px. | width: 120 | | formatter | function | yes | | A callback function which is used to render the cell content. | (val, name, row) => <>{'#' + val}</> | | getSortValue | function | yes | | A callback function which is used to sort rows. | (val, name, row) => dateToIso(val); | | getFilterValue | function | yes | | A callback function which is used to filter rows. | (val, name, row) => dateToGermanDate(val); | | onEdit | function | yes | | A callback function which is called, when the row is edited. | (val, field, row, index) => alert(val); | | type | 'button', 'checkbox', 'color' * | yes | text | HTML5 input types. Used to render edit input fields. | type: 'date', | | editable | boolean | yes | false | If true, the cell can be edited by double clicking on it. | editable: true |

* 'button' | 'checkbox' | 'color' | 'date' | 'datetime' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'

DatatableProps

Interface to configure the table itself.

| Property | Type | Optional | Default | Purpose | Example | |--------------------------|----------------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------| | fields | Field[] | no | | The field definitions to be used by the table. | fields: [{name: 'name', identifier: 'name'}] | | data | any[] | no | | The data to be presented in the table. | [{name: 'Johnny Lawrence'}, {name: 'Daniel LaRusso'}] | | showFilter | boolean | yes | false | If true the filter widget above the table is is visible. | showFilter: true | | hideResultCount | boolean | yes | false | If true the result count above the table is is invisible. | hideResultCount: true | | identifier | string | yes | 'filter' | Used to discriminate different tables on a page. The main purpose is: It is used in the location portion of the URL, to decide, to which table a filter belongs. | identifier: 'mainTable' | | lang | string | yes | 'en' | Used for i18n. Currently only English and German is available. | lang: 'de' | | showDownload | boolean | yes | false | When true, a download button will be visible in top of the table. | showDownload: true | | customDownloadFunction | (tableData: any[]) => void | yes | | Callback function, which will be triggered when clicking the download button (showDownload must be set to true) | customDownloadFunction: (tableData: any[]) => apiCall() | | pageSize | number | yes | 1000 | Amount of rows which will be presented in viewport before rerendering the next chunk. When onFetchAdditionalResults is set, it will be triggered when the amount is reached. | pageSize: 100 | | onFetchAdditionalResults | () => void | yes | | Callback function which will be triggered when the user scolls to the bottom to the table. Uses pageSize. | onFetchAdditionalResults: (tableData: any[]) => apiCall() | | disableSorting | boolean | yes | false | If true, the cell can be edited by double clicking on it. | disableSorting: true | | showRowFilters | boolean | yes | false | If true the row filter inputs will be visible. | showRowFilter: true | | pageSize | number | yes | | If provided, it will be used as the total amount of data instead of the data length. | pageSize: 100 |

You can find a working example on CodeSandbox.

Contributions are welcome!