Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

useImage.d.ts 861B

12345678910111213141516171819202122232425262728293031
  1. declare type State = {
  2. image: HTMLImageElement | null;
  3. error: unknown | null;
  4. };
  5. /**
  6. * Fetch and load an image for programatic use such as in a `<canvas>` element.
  7. *
  8. * @param imageOrUrl The `HtmlImageElement` or image url to load
  9. * @param crossOrigin The `crossorigin` attribute to set
  10. *
  11. * ```ts
  12. * const { image, error } = useImage('/static/kittens.png')
  13. * const ref = useRef<HTMLCanvasElement>()
  14. *
  15. * useEffect(() => {
  16. * const ctx = ref.current.getContext('2d')
  17. *
  18. * if (image) {
  19. * ctx.drawImage(image, 0, 0)
  20. * }
  21. * }, [ref, image])
  22. *
  23. * return (
  24. * <>
  25. * {error && "there was a problem loading the image"}
  26. * <canvas ref={ref} />
  27. * </>
  28. * ```
  29. */
  30. export default function useImage(imageOrUrl?: string | HTMLImageElement | null | undefined, crossOrigin?: 'anonymous' | 'use-credentials' | string): State;
  31. export {};