i am using ant design with react to generate an editable table with a select option inside it i will fetch the select options using a hook (figbird) which will take some time to fetch but the select will render with no option inside it . i tried to but the data ( an array of Options) inside a state like this
const lines = useFind("lines");
let [lineNumber, setLineNumber] = useState();
const options = {
lines: [],
};
if (lines.error) return "Failed to load resource Machine Status";
if (lines.status === "loading") {
options.lines[0] = {};
setLineNumber[0] = { value: "loading" };
} else {
let arr = lines.data.map((line, i) => {
console.log(i, line);
options.lines[i] = {};
return { value: line.line_number };
});
setLineNumber = arr;
}
and then render my table and select component inside it
<Formik
initialValues={{ machine_name: "", password: "", remember: false }}
validationSchema={LoginSchema}
onSubmit={onSubmit}
>
{({ values, handleSubmit }) => (
<Form {...layout} onSubmit={handleSubmit}>
<Form.Item name="machine_name" label="Name">
<Input
name="machine_name"
placeholder="Machine Name"
prefix={<TagOutlined />}
value={values.machine_name}
/>
</Form.Item>
<Form.Item name="machine_line" label="Line">
<Select
prefix={<ClusterOutlined />}
name="machine_line"
style={{ width: "100%" }}
value={values.machine_line}
>
{lineNumber.map((line) => {
return (
<Option value={line.line_number}>
{line.line_number}
</Option>
);
})}
</Select>
</Form.Item>
<Form.Item name="url" label="URL">
<Input
name="url"
placeholder="URL"
prefix={<LinkOutlined />}
value={values.url}
/>
</Form.Item>
<Row>
<Col offset={6} span={4}>
<SubmitButton>Submit</SubmitButton>
</Col>
<Col offset={5} span={4}>
<ResetButton>Reset</ResetButton>
</Col>
</Row>
,
</Form>
)}
</Formik>
but the select still render nothing inside it ... i checked the data returnd from the fetch and it's coming with no error but the state seems like is not been set