Skip to content

Instantly share code, notes, and snippets.

View pubudu-pagero's full-sized avatar

Pubudu Jayasanka pubudu-pagero

View GitHub Profile
const ComponentC = React.memo(({ name }) => {
console.log("Component C is rendered :" + name)
return <h1>Hello , {name}</h1>;
})
@pubudu-pagero
pubudu-pagero / componentA.js
Last active April 12, 2020 14:35
React-memo example code
import React, { useEffect, useMemo, useState } from "react";
const ComponentA = () => {
const [{count,name}, setValues] = useState({count: 0, name: "test"})
setInterval(() => {
setValues(currentValues => ({
...currentValues,
count: currentValues.count + 1