trying to make a API call , and based on that i want to show options in select field when the page load. I am storing the data from API call in a state and then i want to displaying that data as options, i have tried a lot of things but nothing seems working. How can i achieve this in a clean way. Thanks for any kind of help.
Code
const AddNew = () =>{
const [displayData, setDisplayData] = useState();
const fetchResellerData = () =>{
const data = request.fetchData();
setDisplayData(data);
console.log("testing in progress")
console.log(data);
}
useEffect(() => {
fetchResellerData();
}, [])
return (
<form>
<Form.Item label="Status">
{getFieldDecorator("status", {
rules: [{
required: true,
message: "Please enter a valid status",
},
],
})(
<Select>
{displayData && Object.values(displayData.activity_status).map((status) => (
<Select.Option key={status} value={status}>
{status}
</Select.Option>
))}
</Select>
)}
</Form.Item>
</form>
)}