Skip to content

Instantly share code, notes, and snippets.

@enpitsuLin
Created August 8, 2025 09:22
Show Gist options
  • Select an option

  • Save enpitsuLin/ec7563684228b0b9c4af9f5d26e087f6 to your computer and use it in GitHub Desktop.

Select an option

Save enpitsuLin/ec7563684228b0b9c4af9f5d26e087f6 to your computer and use it in GitHub Desktop.
'use client'
import { useIsomorphicLayoutEffect } from 'some-lib-or-your-source'
import { DependencyList, useState } from 'react'
export function useSupport(assert: () => boolean, deps: DependencyList = []) {
const [support, setSupport] = useState(false)
useIsomorphicLayoutEffect(() => {
setSupport(assert())
}, deps)
return support
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment