{"record":{"id":"ab85f77e34b74a86","repo":"remotion-dev/remotion","slug":"the-loop-prop-must-be-a-boolean-or-undefined-bu","errorCode":null,"errorMessage":"The \"loop\" prop must be a boolean or undefined, but is \"${JSON.stringify(loop)}\"","messagePattern":"The \"loop\" prop must be a boolean or undefined, but is \"(.+?)\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lottie/src/validate-loop.ts","lineNumber":7,"sourceCode":"export const validateLoop = (loop: unknown) => {\n\tif (typeof loop === 'undefined') {\n\t\treturn;\n\t}\n\n\tif (typeof loop !== 'boolean') {\n\t\tthrow new TypeError(\n\t\t\t`The \"loop\" prop must be a boolean or undefined, but is \"${JSON.stringify(\n\t\t\t\tloop,\n\t\t\t)}\"`,\n\t\t);\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":14,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lottie/src/validate-loop.ts#L1-L14","documentation":"validateLoop rejects any `loop` prop that is not undefined or a strict boolean. Lottie's loop behavior is binary, so passing a number (a legacy lottie-web convention like loop:3) or a string will not behave as expected and is rejected up front.","triggerScenarios":"Passing loop as a number (e.g. 3 from old lottie-web examples), 'true' string, or null.","commonSituations":"Copying lottie-web snippets that use numeric loop counts; reading loop from a JSON config where it arrives as 1/0 instead of true/false.","solutions":["Pass a boolean: `loop={true}` or omit it.","If you need a finite loop count, drive it via the Remotion timeline (sequence the <Lottie> per loop) rather than a numeric prop.","Coerce config values with Boolean() before passing."],"exampleFix":"// before\n<Lottie animationData={anim} loop={3} />\n// after\n<Lottie animationData={anim} loop={true} />","handlingStrategy":"type-guard","validationCode":"function asLoop(v: unknown): boolean | undefined {\n  return typeof v === 'boolean' ? v : undefined;\n}","typeGuard":"const isLoopable = (v: unknown): v is boolean => typeof v === 'boolean';","tryCatchPattern":null,"preventionTips":["Pass loop as a boolean literal or omit it.","Coerce config values with Boolean() if they come from JSON as 0/1.","For finite loop counts, sequence the <Lottie> multiple times instead of using a number.","Type your wrapper prop as `loop?: boolean` to catch numeric values at compile time."],"tags":["typescript","lottie","validation","props"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}