Open sujoys10 opened 4 years ago
Hi @bladey
I got similar problem when I was using "async" and "await" in my loadOptions function
onSelectChange = _.debounce(async (inputValue, callback) => {
const response = await axios.get('/users');
callback(response.data);
}, 800)
When I changed to Promises axios, it works as expected:
onSelectChange = _.debounce((inputValue, callback) => {
axios.get('/users').then(response => {
calback(response.data);
})
}, 800)
Thanks for the further information @efriandika
In reference to this you can stringify your options whenever they update, and assign that string as a key to AsyncSelect. This causes a re-render.
I have two async form field. Based on the selection of first field, 2nd field fetches data through loadOptions function. I observed that the with input change in the first field, the loadOptions of 2nd filed is not re-executing. How fix this issue?
`import React, { useState, useEffect } from 'react' import { useHistory } from 'react-router-dom' import { useApolloClient} from 'react-apollo'; import { Formik, Form, ErrorMessage } from 'formik'; import * as Yup from "yup"; import AsyncSelect from 'react-select/async' import AsyncPaginate from 'react-select-async-paginate' import { GET_ITEM_CODES, GET_ITEMCODE_SPECIFICATIONS } from '../../library/Query';
}`