I am trying to create a custom input field using typescript and Formik. Could I please get some help on the best way of completing the code below? I need to add in additional props label & name... I have been stuck on this for a while and am hoping that I am missing something very easy here!?
{/* {label && <label htmlFor={name} className="text-input-label">{label}</label>} */}
Please see the above line in the below code.
import React from "react";
import styled from "styled-components";
import { FieldHookConfig, useField } from "formik";
interface AdditionalProps {
label: string;
name: string;
}
const MyTextInput = (props: FieldHookConfig<string>) => {
const [field, meta] = useField(props);
return (
<div className={"text-input " + props.className}>
{/* {label && <label htmlFor={name} className="text-input-label">{label}</label>} */}
<div className="card-backdrop">
<input {...field} placeholder={props.placeholder} />
</div>
</div>
);
};
export default styled(MyTextInput)``
Thank you!!!
props: FieldHookConfig<string> & { name: string, label: string }