[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
901 B

import React, { FC } from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { useTheme } from '../../hooks'
import { setFieldValue } from '../../actions/forms'
import { getFieldValue } from '../../selectors/forms'
import { AppState } from '../../types'
interface Props {
name: string
}
const CheckboxField: FC<Props> = ({ name, children }) => {
const theme = useTheme()
const value = useSelector<AppState, boolean>(state => getFieldValue<boolean>(state, name, false))
const dispatch = useDispatch()
return (
<label className="checkbox">
<input type="checkbox" checked={value} onChange={e => dispatch(setFieldValue(name, e.target.checked))} style={{ color: theme.primary, border: 'none' }} />
&nbsp;&nbsp;
<span style={{ color: theme.text }}>{children}</span>
</label>
)
}
export default CheckboxField