App.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import PropTypes from "prop-types";
  2. import React, { Component } from "react";
  3. import logo from "./logo.svg";
  4. import "./App.css";
  5. const appName = "MasterControlProgram";
  6. const titleName = "heading";
  7. class Link extends Component {
  8. render() {
  9. return this.props.hide
  10. ? null
  11. : <a href={this.props.address}>Click</a>;
  12. }
  13. }
  14. Link.propTypes = {
  15. address: PropTypes.string,
  16. hide: PropTypes.bool,
  17. };
  18. const Title = ({ text }) => <div>{text}</div>;
  19. Title.propTypes = {
  20. text: PropTypes.string,
  21. };
  22. class App extends Component {
  23. state = {
  24. input: "",
  25. on: false,
  26. };
  27. render() {
  28. return (
  29. <div className="App">
  30. <header className="App-header">
  31. <img src={logo} className="App-logo" alt="logo" />
  32. <h1 className="App-title">Welcome to React</h1>
  33. </header>
  34. <Title text="Some title" />
  35. <p className="App-intro">
  36. To get started, edit <code>src/App.js</code> and save to reload.
  37. </p>
  38. <ul className="tyler">
  39. <li>First</li>
  40. <li>Second</li>
  41. <li>Third</li>
  42. </ul>
  43. <p className="button-state">{this.state.on ? "Yes!" : "No!"}</p>
  44. <button onClick={() => this.setState({ on: true })}>Click</button>
  45. <h2>{this.state.input}</h2>
  46. <input type="text" onChange={(e) => this.setState({ input: e.currentTarget.value })} />
  47. </div>
  48. );
  49. }
  50. }
  51. App.displayName = appName;
  52. Title.displayName = titleName;
  53. export { App, Link, appName, titleName };