1.0.0 • Published 6 months ago

react-data-tables-plugin v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

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 NameTypeRequiredDescription
columnsArray of Objects (IColumn[]) with 'title' (string) and 'data' (string) propertiestrueAn 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.
dataArray of Objects (IRow[]) with string keys and string valuestrueAn array of objects where each object represents a row of data with string keys and string values.
classNamestringfalseCustom class name for styling (optional).
mainColorstringfalseThe main color for custom styling (optional).
accentColorstringfalseThe 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.

0.1.52

6 months ago

1.0.0

6 months ago

0.1.50

6 months ago

0.1.51

6 months ago

0.1.49

6 months ago

0.1.41

6 months ago

0.1.42

6 months ago

0.1.43

6 months ago

0.1.45

6 months ago

0.1.46

6 months ago

0.1.47

6 months ago

0.1.48

6 months ago

0.1.40

6 months ago

0.1.38

7 months ago

0.1.39

6 months ago

0.1.30

7 months ago

0.1.31

7 months ago

0.1.32

7 months ago

0.1.33

7 months ago

0.1.34

7 months ago

0.1.35

7 months ago

0.1.36

7 months ago

0.1.37

7 months ago

0.1.27

7 months ago

0.1.28

7 months ago

0.1.29

7 months ago

0.1.20

7 months ago

0.1.21

7 months ago

0.1.22

7 months ago

0.1.23

7 months ago

0.1.24

7 months ago

0.1.25

7 months ago

0.1.26

7 months ago

0.1.16

7 months ago

0.1.17

7 months ago

0.1.18

7 months ago

0.1.19

7 months ago

0.1.15

8 months ago

0.1.14

8 months ago

0.1.13

8 months ago

0.1.12

8 months ago

0.1.11

8 months ago

0.1.10

8 months ago

0.1.9

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

9 months ago

0.1.0

9 months ago