Skip to content

Instantly share code, notes, and snippets.

View mamadOuologuem's full-sized avatar
🏠
Working from home

Mamadou Ouologuem mamadOuologuem

🏠
Working from home
View GitHub Profile
@mamadOuologuem
mamadOuologuem / muiDividerWithMiddleText.jsx
Last active August 10, 2021 05:38
A Material Divider with text in middle
import React from "react";
import { Grid, Divider as MuiDivider } from "@material-ui/core";
const Divider = ({ children, ...props }) => (
<Grid container alignItems="center" spacing={3} {...props}>
<Grid item xs>
<MuiDivider />
</Grid>
<Grid item>{children}</Grid>
<Grid item xs>
@mamadOuologuem
mamadOuologuem / usePagination.js
Created December 13, 2020 14:51
Hooks for pagination in React with a given window view
import { useState } from 'react';
import { inRange } from 'lodash';
function getSliceStartIndex(activeIndex, total, perSlice) {
const sliceStartIndex = activeIndex - Math.floor(perSlice / 2);
if (sliceStartIndex < 0) {
return 0;
}
if (sliceStartIndex > total - perSlice) {