Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { PureComponent } from "react";
- import ReactDOM from "react-dom";
- import "./styles.css";
- const withState = render =>
- class extends PureComponent {
- state = { value: "xxx" };
- onChange = event => this.setState({ value: event.target.value });
- render = () => render(this);
- };
- const Form = ({ state, onChange }) => (
- <div className="App">
- <h1>{state.value}</h1>
- <input value={state.value} onChange={onChange} />
- </div>
- );
- const FormWithState = withState(Form);
- const App = () => (
- <React.Fragment>
- <FormWithState />
- </React.Fragment>
- );
Add Comment
Please, Sign In to add comment