Skip to content

Instantly share code, notes, and snippets.

View SaimumIslam's full-sized avatar

Saimum Islam SaimumIslam

View GitHub Profile
@SaimumIslam
SaimumIslam / re-render-callback-problem-solve.jsx
Created October 15, 2022 12:29
re-render-callback-problem-sovle react
import React, { useState, useCallback, useMemo } from "react";
function Number({ number, onClick }) {
console.log("number render");
return (
<div>
<p>Number:{number}</p>
<button onClick={onClick}>Numbering</button>
</div>
);
@SaimumIslam
SaimumIslam / re-render-callback-problem.jsx
Created October 15, 2022 11:56
callback problem function passing re render react
import React, { useState, useMemo } from "react";
function Number({ number, onClick }) {
console.log("number render");
return (
<div>
<p>Number:{number}</p>
<button onClick={onClick}>Numbering</button>
</div>
);
@SaimumIslam
SaimumIslam / re-render-solve.js
Last active October 15, 2022 11:54
React re-render solve using react.memo,useMemo
import React, { useState, useMemo } from "react";
const Number = React.memo(({ number }) => {
console.log("number render");
return (
<div>
<p>Number:{number}</p>
</div>
);
});
@SaimumIslam
SaimumIslam / re-render.jsx
Last active October 15, 2022 08:09
React re-render.
import React, { useState } from "react";
const Number = ({ number }) => {
console.log("number render");
return (
<div>
<p>Number:{number}</p>
</div>
);
};