Skip to content

Instantly share code, notes, and snippets.

View Nilanth's full-sized avatar

Nilanth Nilanth

View GitHub Profile
@Nilanth
Nilanth / jsx
Created June 13, 2021 15:38
react-17-with-batching
import { useState, useLayoutEffect } from "react";
import * as ReactDOM from "react-dom";
function App() {
const [count, setCount] = useState(0);
const [flag, setFlag] = useState(false);
function handleClick() {
console.log("=== click ===");
setCount((c) => c + 1); // Does not re-render yet