useCallBack and React.memo

 import React,{useCallback} from "react";



export default function TestCallBack() {

// function TestChildFunction() {
// alert("Success");
// }
const TestChildFunction=useCallback(()=>{
alert("Success");
})

return<>
<TestChild onClickFun={TestChildFunction} />
</>
}


const TestChild=React.memo(({onClickFun})=>{

return <>
<button onClick={onClickFun} >Call Function Parent</button>
</>
})

Comments

Popular posts from this blog

App 1st User Define Component

Example 1

Rabiit