I have a requirement to use iframe sandbox in React application. In which, I don't want to allow anything and restrict everything.
So when I am passing sandbox as blank, something like:-
<iframe
frameBorder="0"
ref={(container) => { this.container[index] = container; }}
srcDoc={thread.body}
sandbox
/>
I am getting this - "Warning: Received true
for a non-boolean attribute sandbox
."
react: "^16.5.2"
React treats <iframe sandbox />
just like it was <iframe sandbox={true} />
which is not correct here.
Based on the docs here: https://www.w3schools.com/tags/att_iframe_sandbox.asp, browser expects sandbox prop to be an empty value.
You should simply use
<iframe
frameBorder="0"
ref={(container) => { this.container[index] = container; }}
srcDoc={thread.body}
sandbox=""
/>
EDIT:
As OP answered in the comments, he had to do sandbox="allow-same-origin allow-popups"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With