Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed text/html in react component?

I'm trying to embedding text/html in a react Modal component. But when I run my app with electron the Google Inspector show me some errors.

Uncaught invariant.js:38 Uncaught Invariant Violation: The style prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX. This DOM node was rendered by Example.

SOLUTION : Replace the <object> by <webview>

this is my code

import React from 'react';
import SkyLight from 'react-skylight';

class Example extends React.Component {
  constructor(props){
    super(props);
  }

  render() {
    return (
      <div>
        <section>
          <h1>React SkyLight</h1>
          <button onClick={() => this.refs.simpleDialog.show()}>Ouvrez le modal</button>
        </section>
        <SkyLight  hideOnOverlayClicked ref="simpleDialog" title="Hi, I'm a simple modal">
          <object type="text/html" data="http://www.example.com" style="width:100%; height:100%">
            <p>backup content</p>
          </object>
        </SkyLight>
      </div>
    )
  }
}

Example.displayName = 'Example';

export default Example;
like image 271
kakame91 Avatar asked Jul 17 '26 19:07

kakame91


1 Answers

try to change this line

<object type="text/html" data="http://www.example.com" style="width:100%; height:100%">

with this

    <object type="text/html" data="http://www.example.com" 
style={{width:'100%', height:'100%'}}>

the style attribute expects a json object, for more details you can check this link https://facebook.github.io/react/docs/dom-elements.html#style

like image 96
rakesh Avatar answered Jul 19 '26 09:07

rakesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!