i try to create functional component on React, Typescript and ant ui. But when i create child component i have warning - "Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?". Please tell me where i made mistakes?
CreateCounterpartyComponent:
const CreateCounterpartyComponent: React.FC<FormComponentProps> = props => {
const GET_ALL = gql`
query {
types {
value: id
name: full_name
}
}
`;
const { getFieldDecorator } = props.form;
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log(e);
};
const changeHandler = (e:number) => {
console.log(e)
}
const { loading, data } = useQuery(GET_ALL);
if (loading) return <Loader />;
return (
<div>
<Form onSubmit={handleSubmit}>
<Form.Item hasFeedback>
{getFieldDecorator('address', {
rules: [{ required: true, message: 'Address?' }],
})(<CustomSeletor items={data.types} width="20%" changeEvent={(e)=>changeHandler(e)}/>)}
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" className="login-form-button">
Send
</Button>
</Form.Item>
</Form>
</div>
);
};
export const CreateCounterparty = Form.create()(CreateCounterpartyComponent);
CustomSeletor:
const { Option } = Select;
interface IProps {
items: ISelectorProps[];
width: string;
changeEvent(e:number):void;
}
export const CustomSeletor: React.FC<IProps> = ({ items, width, changeEvent }) => {
const mystyles = {
width: width,
};
const handleChange = (e:number) => {
changeEvent(e)
}
const options = items.map(({ value, name }) => <Option key={value} value={value}>{name}</Option>);
return (
<Select style={mystyles} onChange={handleChange}>
{options}
</Select>
);
};
CreateCounterpartyComponent. in CustomSeletor (at CreateCounterparty.tsx:115) in span (created by Context.Consumer) in div (created by Context.Consumer) in div (created by Context.Consumer) - lobs