File: react.erb

package info (click to toggle)
ruby-capybara 3.40.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,368 kB
  • sloc: ruby: 23,988; javascript: 752; makefile: 11
file content (45 lines) | stat: -rw-r--r-- 1,338 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
  <head>
    <script src="https://unpkg.com/react/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script>
      // https://codepen.io/gaearon/pen/VmmPgp?editors=0010
      class NameForm extends React.Component {
        constructor(props) {
          super(props);
          this.state = { value: '' };

          this.handleChange = this.handleChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);
        }

        handleChange(event) {
          this.setState({ value: event.target.value });
        }

        handleSubmit(event) {
          alert('A name was submitted: ' + this.state.value);
          event.preventDefault();
        }

        render() {
          return (
            React.createElement("form", { onSubmit: this.handleSubmit },
            React.createElement("label", null, "Name:",

            React.createElement("input", { type: "text", value: this.state.value, onChange: this.handleChange })),

            React.createElement("input", { type: "submit", value: "Submit" })));
        }}


        ReactDOM.render(
        React.createElement(NameForm, null),
        document.getElementById('root'));
    </script>
  </body>
</html>