import React from 'react' import { connect } from 'react-redux' import { removeConstraint } from '../actions/constraints' type ConstraintProps = { children?: React.ReactNode | null className?: string index: number title: string value: number | string unit?: string onRemove: (index: number) => any } const Constraint = ({ children, className, index, title, value, unit, onRemove }: ConstraintProps) => { return ( { e.stopPropagation() onRemove(index) }} /> {title} {value} {Number.isNaN(value as any) ? '' : unit} {children} ) } Constraint.defaultProps = { children: null, className: '', unit: '' } export default connect(null, (dispatch: (event: any) => any) => ({ onRemove: (index: number) => dispatch(removeConstraint(index)), }))(Constraint)