Skip to content

Instantly share code, notes, and snippets.

@cdsandoval
Last active February 8, 2024 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdsandoval/30a29182516d13c510b30df92ab09704 to your computer and use it in GitHub Desktop.
Save cdsandoval/30a29182516d13c510b30df92ab09704 to your computer and use it in GitHub Desktop.
useMemo
function Component(){
const [searchTerm, setSearchTerm] = React.useState("")
const filterWithGoodName = React.useMemo(() => {
return searchTerm.filter(.....)
}, [searchTerm])
return (
<input onSearch={setSearchTerm}/>
}
// Aunque lo ideal seria remover el estado de searchTerm y que el useApolloTableQuery devuelva el valor de search que tiene, como lo hace con el onSearchChange.
// Asi evitamos tener 2 estados para lo mismo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment