Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import React, { ReactElement, FC } from 'react' import { Button, FormGroup, Label, Input, CustomInput, FormText, Row, Col } from 'reactstrap' interface Props { children: ReactElement[] | ReactElement } const FormRow: FC<Props> = ({ children }: Props) => { const c = React.Children.toArray(children) const label = c.find(({ type }) => type === Label) || null const input = c.find(({ type }) => type === Input || type === CustomInput) || null const formText = c.find(({ type }) => type === FormText) || null const button = c.find(({ type }) => type === Button) || null return ( <FormGroup> <Row> {label && <Col xs={{ size: 3, offset: 1 }}>{label}</Col>} <Col xs={{ size: 7, offset: label ? 0 : 4 }}> {input} {formText} {button} </Col> </Row> </FormGroup> ) } export default FormRow |