{"record":{"id":"bc1657ba503308dd","repo":"remotion-dev/remotion","slug":"no-src-prop-was-passed-to-img","errorCode":null,"errorMessage":"No \"src\" prop was passed to <Img>.","messagePattern":"No \"src\" prop was passed to <Img>\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/Img.tsx","lineNumber":385,"sourceCode":"\tfrom,\n\ttrimBefore,\n\tdurationInFrames,\n\tfreeze,\n\tpremountFor,\n\tpostmountFor,\n\tstyle,\n\tstyleWhilePremounted,\n\tstyleWhilePostmounted,\n\tcropLeft,\n\tcropRight,\n\tcropTop,\n\tcropBottom,\n\tcontrols,\n\toutlineRef: refForOutline,\n\t...props\n}) => {\n\tif (!src) {\n\t\tthrow new Error('No \"src\" prop was passed to <Img>.');\n\t}\n\n\tconst isMedia = useMemo(\n\t\t() => ({\n\t\t\ttype: 'image' as const,\n\t\t\tsrc,\n\t\t}),\n\t\t[src],\n\t);\n\n\tconst {\n\t\teffectivePostmountFor,\n\t\teffectivePremountFor,\n\t\tfreezeFrame,\n\t\tisPremountingOrPostmounting,\n\t\tpostmountingActive,\n\t\tpremountingActive,\n\t\tpremountingStyle,","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/core/src/Img.tsx#L367-L403","documentation":"Thrown by the NativeImgInner component (the path <Img> takes when no `effects` prop is passed) when `src` is falsy. <Img> always requires a `src` because it is responsible for suspending rendering until the image is decoded; an undefined src would silently produce a blank frame. This is the validation guard at the top of the native-rendering branch of <Img>.","triggerScenarios":"Rendering `<Img />` without a src prop; passing `src={undefined}` while a value loads; destructuring an object that lacks the src field; passing src from a state variable that is initialized to undefined.","commonSituations":"Loading images from props where the field is optional; CMS data where the URL field can be empty; conditional rendering forgotten when the asset is missing.","solutions":["Always pass a valid `src` string URL to <Img>.","Defer rendering: `{url && <Img src={url} />}` so the component never mounts without src.","Provide a placeholder image URL as a fallback.","Validate upstream data sources to ensure the src field is non-empty before passing to <Img>."],"exampleFix":"// before\n{props.image && <Img alt={props.image.alt} />}\n// after\n{props.image?.url && <Img src={props.image.url} alt={props.image.alt} />}","handlingStrategy":"type-guard","validationCode":"if (typeof src !== 'string' || src.length === 0) {\n  throw new Error(`Missing <Img> src`);\n}\nreturn <Img src={src} />;","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Conditionally render <Img> only when src is truthy.","Provide a placeholder src as a fallback.","Type the src prop as `string` (not optional) in your wrappers.","Validate CMS/JSON image fields before forwarding to <Img>."],"tags":["img","src","props","validation"],"backgroundTag":null,"analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}