Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { Form, FormApi, NestedField, Text } from 'react-form';
  3. import './App.css';
  4.  
  5. class App extends Component {
  6.   render() {
  7.     return (
  8.       <div className="App">
  9.         <Form component={FormContent} />
  10.       </div>
  11.     );
  12.   }
  13. }
  14.  
  15. export default App;
  16.  
  17. class FormContent extends React.Component {
  18.   componentDidMount() {
  19.     const { formApi } = this.props;
  20.     formApi.setAllValues({
  21.       hello: 'hello',
  22.       parent: {
  23.         hi: 'hi'
  24.       }
  25.     });
  26.   }
  27.   render() {
  28.     return (
  29.       <form onSubmit={this.props.formApi.submitForm}>
  30.         <Text field="hello" id="hello" />
  31.         <br />
  32.         <NestedField
  33.           field="parent"
  34.           id="parent"
  35.           render={() => <Text field="hi" id="hi" />}
  36.         />
  37.         <button type="submit">Submit</button>
  38.       </form>
  39.     );
  40.   }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement