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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-data-tables-plugin

v1.0.0

Published

Note: This project was developed as part of the JS/React Application Developer training program at OpenClassrooms. It is a partial adaptation of the jQuery DataTables plugin (https://datatables.net/).

Downloads

190

Readme

react-data-tables-plugin

Note: This project was developed as part of the JS/React Application Developer training program at OpenClassrooms. It is a partial adaptation of the jQuery DataTables plugin (https://datatables.net/).

Introduction

react-data-tables-plugin is a React component for displaying data in tabular format. It provides various features to manage and customize the presentation of your data. This plugin is designed to simplify the process of integrating data tables into your React applications.

Features

  • Display data in a tabular format.
  • Sort data by columns in ascending or descending order.
  • Control the number of entries per page.
  • Implement search and filtering capabilities.
  • Display pagination for easy navigation through large data sets.
  • Color scheme customization to match your application's style.

Installation

You can install the react-data-tables-plugin via npm:

npm install react-data-tables-plugin

Usage

To use react-data-tables-plugin, you need to import it into your React application and pass the necessary data and configuration as props. Here's a very basic example of how to use the plugin:

import React from "react";
import DataTable from "react-data-tables-plugin";

const columns = [
  {
    title: "First Name",
    data: "firstName",
  },
  {
    title: "Last Name",
    data: "lastName",
  },
  {
    title: "Age",
    data: "age",
  },
];

const data = [
  {
    firstName: "John",
    lastName: "Doe",
    age: "30",
    id: "my-id-1",
  },
  {
    firstName: "Jane",
    lastName: "Smith",
    age: "25",
    id: "my-id-2",
  },
];
// Note: Ensure that each data object has an 'id' property with a unique string identifier.
// Refer to the "Performance" section for more details.

function App() {
  return (
    <div>
      <DataTable columns={columns} data={data} />
    </div>
  );
}

export default App;

Screenshot of this basic example

Configuration

Properties

| Prop Name | Type | Required | Description | | --- | --- | --- | --- | | columns | Array of Objects (IColumn[]) with 'title' (string) and 'data' (string) properties | true | An array of objects that define the configuration of table columns. Each object should have a 'title' property (string) for the column title and a 'data' property (string) specifying the data key to display in that column. | | data | Array of Objects (IRow[]) with string keys and string values | true | An array of objects where each object represents a row of data with string keys and string values. | | className | string | false | Custom class name for styling (optional). | | mainColor | string | false | The main color for custom styling (optional). | | accentColor | string | false | The accent color for custom styling (optional). |

Performance

This plugin incorporates performance optimizations:

  • Components are wrapped with React.memo to prevent unnecessary re-renders. React.memo is a higher-order component that memoizes the rendered output of a component, preventing re-renders if the input props remain unchanged.

  • It is very important for optimal performance that objects passed as props to construct the table body include a unique 'id' property. This uniqueness enables the avoidance of unnecessary re-renders. The 'id' property is utilized as the 'key' for each object displayed in the table. To generate unique identifiers, consider using libraries such as uuid.

Reporting Issues

Please note that this project is part of a training program and maintenance cannot be guaranteed but if you come across any issues or have suggestions for improvements, please don't hesitate to open an issue on the GitHub Issues page.