Skip to content

Instantly share code, notes, and snippets.

@Mohammad-Faisal
Last active April 22, 2022 03:15
Show Gist options
  • Save Mohammad-Faisal/9f9efea49e187188a5917f20d2fbb76a to your computer and use it in GitHub Desktop.
Save Mohammad-Faisal/9f9efea49e187188a5917f20d2fbb76a to your computer and use it in GitHub Desktop.
import React, { useState } from "react";
export const TestMemo = () => {
const [userName, setUserName] = useState("faisal");
const [count, setCount] = useState(0);
const increment = () => setCount((count) => count + 1);
return (
<>
<ChildrenComponent userName={userName} />
<button onClick={increment}> Increment </button>
</>
);
};
const ChildrenComponent =({ userName }) => {
console.log("rendered", userName);
return <div> {userName} </div>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment