Reputation: 838
I'm using an iframe:
<iframe
width="100%"
height="100%"
frameBorder="0"
title="Spline 3D Animation"
allowTransparency={true}
style={{ backgroundColor: "transparent" }}
src="https://my.spline.design/portfolio-fe0fd4b29cba7bfea175804f995a9f8a/">
</iframe>
The console shows:
Warning: React does not recognize the `allowTransparency` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `allowtransparency` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
React version: ^17.0.2
Link to code example: The entire code for this is here https://github.com/akashshyamdev/portfolio-latest/blob/master/src/containers/Home/Hero.tsx
I expect the black background to be transparent
Upvotes: 5
Views: 3320
Reputation: 580
Short answer: Just remove this property and have fun.
Explanation:
I'm having the same issue with React and Typescript.
The problem is that the property allowTransparency
is typed in @types/react
, but it's no longer supported in React - it was removed in 2017.
@types/react
is an independent project https://github.com/DefinitelyTyped/DefinitelyTyped and someone has already tried to merge a PR removing this property but it was not merged.
nhunzaker, the guy who removed this property from React with this PR said:
"allowtransparency is an Internet Explorer-only attribute that controls the background transparency of an iFrame. When set to true, it respects the background color of the iFrame. When set to false, it sets the background color to that of the document."
Nobody is really using Internet Explorer these days, so I'm just removing it.
If you still need to support IE, you can try using @ts-ignore.
I hope it helps, good luck!
Upvotes: 4
Reputation: 7680
If allowtransparency
, or allowTransparency
or anything doesn't work, you still can try with CSS.
iframe {
background-color: transparent;
}
Upvotes: 2