Skip to content

Instantly share code, notes, and snippets.

@alex-streza
Created April 2, 2023 09:20
Show Gist options
  • Select an option

  • Save alex-streza/a6f3385c62d488f9350478d22f3a74da to your computer and use it in GitHub Desktop.

Select an option

Save alex-streza/a6f3385c62d488f9350478d22f3a74da to your computer and use it in GitHub Desktop.
GSAP Context Hook for React
const useGsapContext = (
func: gsap.ContextFunc,
deps: any[] = [],
target?: any,
) => {
useEffect(() => {
const ctx = gsap.context(func, target)
return () => ctx?.revert()
}, deps)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment