Last active
May 6, 2021 09:32
-
-
Save ChaseH88/0e0782a2bdc5d32725762c8b290504b1 to your computer and use it in GitHub Desktop.
This is a quick example of how you can use the useMemo hook on a child component. I realize this component is technically incomplete, but you get the idea..
This file contains hidden or 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
| import React, { FC, useMemo } from "react"; | |
| interface MyComponentInterface { | |
| text: string | |
| } | |
| export const MyComponent: FC<MyComponentInterface> = ({ text }) => { | |
| const MemoizedComponent = useMemo(() => ( | |
| <Component | |
| prop1={'somePropData'} | |
| prop2={'someMorePropData'} | |
| /> | |
| ), [text]); | |
| return( | |
| <div> | |
| Use Memo Example for a Component! | |
| {MemoizedComponent} | |
| </div> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment