Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react'
- import {Input as RInput} from 'reactstrap'
- const getCheckboxProps = ({onChange}) => ({
- onChange: (e) => {
- const label = e.target.closest('form-check-label');
- if(label){
- label.classList.toggle('checked')
- } else {
- console.error('checkin - !label')
- }
- onChange && onChange(e)
- }
- })
- const getElemProps = ({...props}) => {
- switch (props.type) {
- case 'checkbox': return getCheckboxProps(props)
- default : return {}
- }
- }
- const Input = ({...props}) => {
- props = {...props,...getElemProps(props)}
- return (<RInput {...props} />)
- }
Advertisement
Add Comment
Please, Sign In to add comment