admin管理员组文章数量:1356914
I developed a website in reactjs using typescript, but Im far from beign an expert.
Selectors for filtering by any country, state or city are very important in my application, so I implemented them using country-state-city library, but iPhone users started having issues. I dont own an iPhone so by using BrowserStack I found out that the problem was this library because its heavy and its unmaintained.
Found a workaround to get the country and region selectors working, but cities are too heavy and still throws the error. I considered creating a fork and try to make it work but maybe there is another solution or workaround for my use case. This is the code that throws the error (I used the same logic to the country and regions):
export const CityOrCommuneSelect: React.FC<CityOrCommuneSelectProps> = ({ placeholder, handleSetValue, countryCode, stateCode, isClearable=false }) => {
const [newCities, setNewCities] = useState<{ label: string; value: string }[]>([]);
const getCities = async (country: string, state: string) => {
const City = await import('country-state-city/lib/city');
const {getCitiesOfState} = City.default;
return getCitiesOfState(country, state);
}
useEffect(() => {
const fetchCities = async () => {
if (!countryCode || !stateCode) return;
const fetchedCities = await getCities(countryCode, stateCode);
const formattedCities = fetchedCities.map((val) => ({
label: val.name,
value: val.name,
}));
setNewCities(formattedCities);
};
fetchCities();
}, [countryCode, stateCode]);
return (
<Select isClearable={isClearable} placeholder={placeholder} styles={customStyles} noOptionsMessage={() => "elige pais y región"} options={newCities} onChange={ val => handleSetValue("cityOrCommune", val?.value || '') } />
)
}
is there a way to load this in a different way to avoid this error?
本文标签: iosMaximum call stack exceeded error in iphone devicesStack Overflow
版权声明:本文标题:ios - Maximum call stack exceeded error in iphone devices - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744028933a2578552.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论