Skip to content

Commit 2d35e25

Browse files
committed
fix: allow useRiveFile to work with undefined input
1 parent 24ce242 commit 2d35e25

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/hooks/useRiveFile.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type RiveFileHookResult =
7373
| { riveFile: null; isLoading: false; error: string };
7474

7575
export function useRiveFile(
76-
input: RiveFileInput,
76+
input: RiveFileInput | undefined,
7777
options: UseRiveFileOptions = {}
7878
): RiveFileHookResult {
7979
const [result, setResult] = useState<RiveFileHookResult>({
@@ -95,6 +95,14 @@ export function useRiveFile(
9595
try {
9696
const currentInput = input;
9797

98+
if (currentInput == null) {
99+
setResult({
100+
riveFile: null,
101+
isLoading: false,
102+
error: 'No Rive file input provided.',
103+
});
104+
return;
105+
}
98106
if (typeof currentInput === 'string') {
99107
if (
100108
currentInput.startsWith('http://') ||

0 commit comments

Comments
 (0)