Skip to content

Instantly share code, notes, and snippets.

View stephengade's full-sized avatar

Stephen Gbolagade stephengade

View GitHub Profile
@stephengade
stephengade / usePaginate.ts
Last active December 9, 2023 21:48
React (and Nextjs) Custom Hooks for Data Pagination
import { iProfile } from "@/services/data" // import the data types
import axios from "axios"
import { useCallback, useEffect, useState } from "react"
// if you are using Mockup Data
// We don't know or have access to the data in this hook, so we are passing `data` as a placeholder argument
// We also don't know the limit yet, we simply pass `limit` as argument
export const useMockPaginate = (data: iProfile[], limit: number) => {
@stephengade
stephengade / data.ts
Created December 3, 2023 08:54
Generate Random User Data with For Loop
export interface iProfile {
name: string;
email: string;
photo: string;
username: string;
role: "Frontend Developer" | "Backend Developer" | "Fullstack Developer";
}
export const data: iProfile[] = [];
@stephengade
stephengade / StaffTable.tsx
Created July 24, 2023 21:00
How to Build a Powerful Table in ReactJS with Tanstack and Material UI
import React, { useEffect, useState } from "react";
import { Box } from "@mui/material";
// Import these components correctly depending on your structure
import TableUI from "@/components/TableUI/TableUI";
import { Columns } from "./Column";
import {DummyData} from "./dummydata"