File: react.html

package info (click to toggle)
python-playwright 1.55.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,728 kB
  • sloc: python: 53,655; javascript: 383; sh: 216; makefile: 6
file content (33 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<head>
  <script src="./react/react@16.13.1.production.min.js"></script>
  <script src="./react/react-dom@16.13.1.production.min.js"></script>
</head>
<body>
  <div class='react-root'></div>
  <script>
    window.e = React.createElement;
    window.reactRoot = document.querySelector('.react-root');
    window.renderComponent = c => ReactDOM.render(c, window.reactRoot);

    window.MyButton = class MyButton extends React.Component {
      constructor(props) {
        super(props);
        this.state = { hovered: false };
      }
      render() {
        return e('button', {
          disabled: !!this.props.disabled,
          onClick: () => {
            window[this.props.name] = true;
          },
          onMouseEnter: () => {
            if (this.props.renameOnHover)
              this.setState({ hovered: true });
            if (this.props.onHover)
              this.props.onHover();
          },
        }, this.state.hovered ? 'Hovered' : this.props.name);
      }
    };
  </script>
</body>