Skip to content

They Say These Coding Interview Questions Are for Senior Devs, But I Don't Belive Them.

Notifications You must be signed in to change notification settings

rudzky/they-say-its-for-seniors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a reusable table

This is basically a hook called useTable which takes object as a parameter and returns object with two arrays. First is called headers and contains table headers, second is called rows and contains objects, each of which represents a row of data.


Here is simple mocked data

const mockData = [
  {
    id: "1",
    name: "Lucas",
    favouriteFood: "Lasagne",
  },
  {
    id: "2",
    name: "Larry",
    favouriteFood: "Pizza",
  },
];

And here is array of objects, each of which has two params:

  • accessor (which needs to be same as property name in data we're gonna use)
  • label (which is going to be render in table head)
const COLUMNS = [
  {
    accessor: "id",
    label: "ID",
  },
  {
    accessor: "name",
    label: "Name",
  },
  {
    accessor: "favouriteFood",
    label: "Favourite Food",
  },
];
const { headers, rows } = useTable({ columns: COLUMNS, data: mockData });

About

They Say These Coding Interview Questions Are for Senior Devs, But I Don't Belive Them.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published