Skip to content

Instantly share code, notes, and snippets.

@ericelliott
ericelliott / essential-javascript-links.md
Last active May 17, 2024 03:38
Essential JavaScript Links
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@meotimdihia
meotimdihia / How to fix the bug: "Warning: Expected server HTML to contain a matching <div> in <div>." in Next.js.md
Last active December 21, 2022 10:01
How to fix the bug: "Warning: Expected server HTML to contain a matching <div> in <div>." in Next.js

1 Easy but re-render

most simple way, but it will re-render. It may be related to the scrolling restoration bug when the user return the page if your data is fetched on the client

import {useState, useEffect} from 'react'

export default function Index() {
  const [mounted, setMounted] = useState(false);
  useEffect(() => {
      setMounted(true)