Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2.  
  3.  
  4. //You may ask why do i use custom validation, if redux-form has its own?
  5. //Because i can.
  6.  
  7. export default (Component) => class Validate extends React.Component {
  8.   constructor() {
  9.     super()
  10.     this.state = {
  11.       isValidated: false,
  12.     }
  13.   }
  14.  
  15.   render() {
  16.     return <Component {...this.props} {...this.state} validateForm={this.validateForm}
  17.                       isValidated={this.state.validated}/>
  18.   }
  19.  
  20.   validateForm = () => {
  21.     console.log('I WAS CLICKED---------------------------', this.state)
  22.     //validate like a boss
  23.     this.setState({
  24.       isValidated: true
  25.     })
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement