Skip to content

Instantly share code, notes, and snippets.

View junxdev's full-sized avatar

Jun Park junxdev

View GitHub Profile
@junxdev
junxdev / ReactContextRerenderCase.js
Created May 17, 2024 02:56
The cases when React components rerender when it uses Context or Children Props...
import { createContext, useContext, useState } from "react";
const Context = createContext(1);
function ChildrenPropsWithContext() {
const level = useContext(Context);
console.log("ChildrenPropsWithContext"); // prints when the context updates
return <div>with context {level}</div>;
}