Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import React, { PureComponent } from "react";
  2. import ReactDOM from "react-dom";
  3. import "./styles.css";
  4.  
  5. const withState = render =>
  6. class extends PureComponent {
  7. state = { value: "xxx" };
  8. onChange = event => this.setState({ value: event.target.value });
  9. render = () => render(this);
  10. };
  11.  
  12. const Form = ({ state, onChange }) => (
  13. <div className="App">
  14. <h1>{state.value}</h1>
  15. <input value={state.value} onChange={onChange} />
  16. </div>
  17. );
  18.  
  19. const FormWithState = withState(Form);
  20.  
  21. const App = () => (
  22. <React.Fragment>
  23. <FormWithState />
  24. </React.Fragment>
  25. );
Add Comment
Please, Sign In to add comment