-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React useCallback & useMemo H o Hook 🕉☮
- Loading branch information
1 parent
603f953
commit 7f3ee14
Showing
4 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, {memo} from 'react'; | ||
|
||
const Button = ({handleClick, children}) => { | ||
console.log(`Rendering Button ${children}...`) | ||
return ( | ||
<div> | ||
<button type='button' onClick={handleClick}> | ||
{children} | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(Button); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React, {memo} from 'react'; | ||
|
||
const ShowCount = ({count, title}) => { | ||
console.log(`Rendering ShowCount ${title}`) | ||
return ( | ||
<div> | ||
<p> | ||
{title} {count} | ||
</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(ShowCount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, {memo} from 'react'; | ||
|
||
const Title = () => { | ||
console.log('Title Rendering.....'); | ||
return ( | ||
<div> | ||
<h2>useCallback Title</h2> | ||
</div> | ||
); | ||
}; | ||
// Should not use for small rendering because | ||
export default memo(Title); |