test_component.jsx 545 B

12345678910111213141516171819202122232425262728293031
  1. import React from 'react';
  2. class TestComponent extends React.Component {
  3. constructor(props) {
  4. super(props);
  5. this.state = {text: ''};
  6. }
  7. onChange = e => {
  8. this.updateText(e.target.value);
  9. };
  10. updateText = text => {
  11. this.setState({text: text});
  12. };
  13. render() {
  14. return (
  15. <div>
  16. <div>
  17. <h1>React lives!</h1>
  18. </div>
  19. Is React working? Test here: {this.state.text}
  20. <hr />
  21. <input onChange={this.onChange} />
  22. </div>
  23. );
  24. }
  25. }
  26. export default TestComponent;