Plotly React Directly in HTML

How to render the plot using react directly in HTML

<!DOCTYPE html>
    <script src="" crossorigin></script>
    <script src="" crossorigin></script>
    <script src=""></script>

    <script src=""></script>
    <script src=""></script>

    <div id="mydiv"></div>

    <script type="text/babel">
      function Hello() {
        return <h1>Hello World!</h1>;
      const container = document.getElementById('mydiv');
      const root = ReactDOM.createRoot(container);
      root.render(<Hello />)


        <script type="text/babel">
        import React from 'react';
        import Plot from 'react-plotly.js';

        class App extends React.Component {
          render() {
            return (
                    x: [1, 2, 3],
                    y: [2, 6, 3],
                    type: 'scatter',
                    mode: 'lines+markers',
                    marker: {color: 'red'},
                  {type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
                layout={ {width: 320, height: 240, title: 'A Fancy Plot'} }


I think you’re looking for something that’s called, dangerouslysetinnerhtml

From React docs, dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. So, you can set HTML directly from React, but you have to type out dangerouslySetInnerHTML and pass an object with a __html key, to remind yourself that it’s dangerous. For example:

function createMarkup() {
  return {__html: 'First &middot; Second'};

function MyComponent() {
  return <div dangerouslySetInnerHTML={createMarkup()} />;