From 4065da354fb91ec299af356c0284bf10153ce1e2 Mon Sep 17 00:00:00 2001 From: duguyihou Date: Sat, 22 Jun 2024 17:32:34 +1000 Subject: [PATCH] 245 only set one hash string (#246) * feat: only one hash string * docs: update readme --- README.md | 4 ++-- src/TurboImage.tsx | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da199e9..aa20fbe 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ type Placeholder = { }; ``` -show placeholder while loading. +show placeholder while loading, either `thumbhash` or `blurhash` -- [blurhash](https://blurha.sh/) - [thumbhash](https://evanw.github.io/thumbhash/) +- [blurhash](https://blurha.sh/) ### `cachePolicy?: enum` diff --git a/src/TurboImage.tsx b/src/TurboImage.tsx index 69e491d..2ec79b8 100644 --- a/src/TurboImage.tsx +++ b/src/TurboImage.tsx @@ -44,6 +44,10 @@ const TurboImage = (props: TurboImageProps) => { ...restProps } = props; + if (placeholder && Object.keys(placeholder).length > 1) { + throw new Error('Choose one hash string, either thumbhash or blurhash'); + } + const processedIndicator = indicator && Object.keys(indicator).length !== 0 ? {