Skip to content

Instantly share code, notes, and snippets.

@ChaseH88
Last active May 6, 2021 09:32
Show Gist options
  • Select an option

  • Save ChaseH88/0e0782a2bdc5d32725762c8b290504b1 to your computer and use it in GitHub Desktop.

Select an option

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..
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