Set attribute mozallowfullscreen or webkitAllowFullScreen in ReactJs JSX

dba picture dba · Jun 29, 2017 · Viewed 14.3k times · Source

Iam trying to include a Vimeo Iframe in a webpage like this (JSX Code):

<iframe frameBorder="0" width="100%" height="100%" src={this.props.src} webkitAllowFullScreen mozAllowFullScreen allowFullScreen />

What gets rendered is this:

<iframe frameborder="0" width="100%" height="100%" src="https://player.vimeo.com/video/..." allowfullscreen=""></iframe>

How can I implement the needed mozAllowFullScreen and webkitAllowFullScreen Attributes? In the React Docs (https://facebook.github.io/react/docs/dom-elements.html#all-supported-html-attributes) is only the allowfullscreen Attribute mentioned?

Answer

user9735444 picture user9735444 · May 29, 2018

Try to pass true as a string. This works for me (React 16):

<iframe 
  frameBorder="0"
  width="100%" height="100%" 
  src={this.props.src}
  allowFullScreen="true"
  webkitallowfullscreen="true"
  mozallowfullscreen="true"
/>

More details here: https://github.com/facebook/react/issues/7848