unexpected-ivoryU
Refine3y ago
35 replies
unexpected-ivory

Ant d switch doesnot work in form item

import React from 'react';
import { Form, Switch } from 'antd';

interface SwitchInputProps {
label: string;
name: string;
size?: 'default' | 'small'; // Make size prop accept only specific values
}

const SwitchInput = ({ label, name, size }: SwitchInputProps) => {
return (
<Form.Item
name={name}
valuePropName=""
>
<div style={{ display: 'flex' }}>
<h4 style={{ marginRight: "10px" }}>{label}</h4>
<Switch size={size} />
</div>
</Form.Item>
);
};

export default SwitchInput;

when used this it is returning the value as undefined
Was this page helpful?