innot

rest

Apr 11th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import {Input as RInput} from 'reactstrap'
  3.  
  4. const getCheckboxProps = ({onChange}) => ({
  5.     onChange: (e) => {
  6.         const label = e.target.closest('form-check-label');
  7.         if(label){
  8.             label.classList.toggle('checked')
  9.         } else {
  10.             console.error('checkin - !label')
  11.         }
  12.  
  13.         onChange && onChange(e)
  14.     }
  15. })
  16.  
  17.  
  18. const getElemProps = ({...props}) => {
  19.     switch (props.type) {
  20.         case 'checkbox': return getCheckboxProps(props)
  21.         default : return {}
  22.     }
  23. }
  24.  
  25.  
  26. const Input =  ({...props}) => {
  27.     props = {...props,...getElemProps(props)}
  28.     return (<RInput {...props} />)
  29. }
Advertisement
Add Comment
Please, Sign In to add comment