React Table

Last updated on May 28 2022
Nitin Ajmera

Table of Contents

React Table

A table is an arrangement which organizes information into rows and columns. It is used to store and display data in a structured format.
The react-table is a lightweight, fast, fully customizable (JSX, templates, state, styles, callbacks), and extendable Datagrid built for React. It is fully controllable via optional props and callbacks.
Features
1. It is lightweight at 11kb (and only need 2kb more for styles).
2. It is fully customizable (JSX, templates, state, styles, callbacks).
3. It is fully controllable via optional props and callbacks.
4. It has client-side & Server-side pagination.
5. It has filters.
6. Pivoting & Aggregation
7. Minimal design & easily themeable
Installation
Let us create a React app using the following command.
1. $ npx create-react-app myreactapp
Next, we need to install react-table. We can install react-table via npm command, which is given below.
1. $ npm install react-table
Once, we have installed react-table, we need to import the react-table into the react component. To do this, open the src/App.js file and add the following snippet.
1. import ReactTable from “react-table”;
Let us assume we have data which needs to be rendered using react-table.

1. const data = [{ 
2. name: 'Ayaan', 
3. age: 26 
4. },{ 
5. name: 'Ahana', 
6. age: 22 
7. },{ 
8. name: 'Peter', 
9. age: 40 
10. },{ 
11. name: 'Virat', 
12. age: 30 
13. },{ 
14. name: 'Rohit', 
15. age: 32 
16. },{ 
17. name: 'Dhoni', 
18. age: 37 
19. }]

Along with data, we also need to specify the column info with column attributes.

1. const columns = [{ 
2. Header: 'Name', 
3. accessor: 'name' 
4. },{ 
5. Header: 'Age', 
6. accessor: 'age' 
7. }]

Inside the render method, we need to bind this data with react-table and then returns the react-table.

1. return ( 
2. <div> 
3. <ReactTable 
4. data={data} 
5. columns={columns} 
6. defaultPageSize = {2} 
7. pageSizeOptions = {[2,4, 6]} 
8. /> 
9. </div> 
10. )

Now, our src/App.js file looks like as below.

1. import React, { Component } from 'react'; 
2. import ReactTable from "react-table"; 
3. import "react-table/react-table.css"; 
4. 
5. class App extends Component { 
6. render() { 
7. const data = [{ 
8. name: 'Ayaan', 
9. age: 26 
10. },{ 
11. name: 'Ahana', 
12. age: 22 
13. },{ 
14. name: 'Peter', 
15. age: 40 
16. },{ 
17. name: 'Virat', 
18. age: 30 
19. },{ 
20. name: 'Rohit', 
21. age: 32 
22. },{ 
23. name: 'Dhoni', 
24. age: 37 
25. }] 
26. const columns = [{ 
27. Header: 'Name', 
28. accessor: 'name' 
29. },{ 
30. Header: 'Age', 
31. accessor: 'age' 
32. }] 
33. return ( 
34. <div> 
35. <ReactTable 
36. data={data} 
37. columns={columns} 
38. defaultPageSize = {2} 
39. pageSizeOptions = {[2,4, 6]} 
40. /> 
41. </div> 
42. ) 
43. } 
44. } 
45. export default App;

Output
When we execute the React app, we will get the output as below.

reactJs 48
reactJs

Now, change the rows dropdown menu, we will get the output as below.

reactJs 49
reactJs

So, this brings us to the end of blog. This Tecklearn ‘React Table’ blog helps you with commonly asked questions if you are looking out for a job in React JS and Front-End Development. If you wish to learn React JS and build a career in Front-End Development domain, then check out our interactive, React.js with Redux Training, that comes with 24*7 support to guide you throughout your learning period.

React.js with Redux Training

About the Course

Tecklearn’s React JS Training Course will help you master the fundamentals of React—an important web framework for developing user interfaces—including JSX, props, state, and events. In this course, you will learn how to build simple components & integrate them into more complex design components. After completing this training, you will be able to build the applications using React concepts such as JSX, Redux, Asynchronous Programming using Redux Saga middleware, Fetch data using GraphQL, perform Testing using Jest, successively Deploy applications using Nginx and Docker plus build Mobile applications using React Native. Accelerate your career as a React.js developer by enrolling into this React.js training.

Why Should you take React.js with Redux Training?

• The average salary for “React Developer” ranges from $100,816 per year to $110,711 per year, based on the role (Front End Developer/Full Stack Developer) – Indeed.com
• React Native Supports Cross-platform Development (iOS and Android), and it can reduce the development effort by almost 50% without compromising quality or productivity
• Currently, React JS is being used by major companies like Walmart, Netflix, and HelloSign.

What you will Learn in this Course?

Introduction to Web Development and React.js
• Fundamentals of React
• Building Blocks of Web Application Development
• Single-page and Multi-page Applications
• Different Client-side Technologies
• MVC Architecture
• Introduction to React
• Installation of React
• JSX and its use case
• DOM
• Virtual DOM and its working
• ECMAScript
• Difference between ES5 and ES6
• NPM Modules

Components, JSX & Props
• React Elements
• Render Function
• Components
• Class Component
• Thinking In Components
• What Is JSX
• JSX Expressions
• Creating Your First Component
• Functional Components

React State Management using Redux
• Need of Redux
• Redux Architecture
• Redux Action
• Redux Reducers
• Redux Store
• Principles of Redux
• Pros of Redux
• NPM Packages required to work with Redux
• More about react-redux package
React & Redux
• The React Redux Node Package
• Provider Component
• Connecting React Components with Redux Store
• Reducer Composition
• Normalization: Points to Keep in Mind When Designing a Redux Store
• Redux Middleware

React Hooks
• Caveat of JavaScript classes.
• Functional components and React hooks
• What are React hooks?
• Basic hooks
• useState() hook
• How to write useState() hook when state variable is an array of objects
• useEffect() hook
• Fetch API data using useEffect() hook
• useContext() hook
• Rules to write React hooks
• Additional hooks
• Custom hooks

Fetch Data using GraphQL
• What is GraphQL?
• Cons of Rest API
• Pros of GraphQL
• Frontend backend communication using GraphQL
• Type system
• GraphQL datatypes
• Modifiers
• Schemas
• GraphiQL tool
• Express framework
• NPM libraries to build server side of GraphQL
• Build a GraphQL API
• Apollo client
• NPM libraries to build client side of GraphQL
• How to setup Apollo client

React Application Testing and Deployment
• Define Jest
• Setup Testing environment
• Add Snapshot testing
• Integrate Test Reducers
• Create Test Components
• Push Application on Git
• Create Docker for React Application

Introduction to React Native
• What is React Native
• Use of JSX elements With React Native
• The anatomy of a React Native application
• React Native installation and setup
• Running the app on Android Simulator and Android Device
• Working with Styles and Layout
• Connecting React Native to Redux

React with Redux Projects

Got a question for us? Please mention it in the comments section and we will get back to you.

0 responses on "React Table"

Leave a Message

Your email address will not be published. Required fields are marked *