当我尝试破坏React查询的数据时,我将获得属性'在类型上不存在' void;
当我尝试像以下方式破坏数据时,我会面临React查询的问题,const {data:getallChannerSettingTypes} = usegetAllChannerSettingTypes();
我是gettin此错误property'data'不存在在类型的“ void”
上
,也许返回Userqueries存在问题
const useGetAllChannelSettingTypes = () => {
const {data: defaultSettingTypes} = useQuery(SETTING_TYPES, () =>
Api.user.getSettingTypes(),
);
const userQueries = useQueries(
defaultSettingTypes.map((type: any) => {
return {
queryKey: ['SETTING_VALUE', type.channelSettingTypeId],
queryFn: () => Api.user.getSettingValues(type.channelSettingTypeId),
};
}),
);
console.log(userQueries);
return userQueries;
};
I am facing issue with react query when I try to destructing the data like this way const {data: getAllChannelSettingTypes} = useGetAllChannelSettingTypes();
I am gettin this error Property 'data' does not exist on type 'void'
Maybe there is a problem with returning the userQueries
const useGetAllChannelSettingTypes = () => {
const {data: defaultSettingTypes} = useQuery(SETTING_TYPES, () =>
Api.user.getSettingTypes(),
);
const userQueries = useQueries(
defaultSettingTypes.map((type: any) => {
return {
queryKey: ['SETTING_VALUE', type.channelSettingTypeId],
queryFn: () => Api.user.getSettingValues(type.channelSettingTypeId),
};
}),
);
console.log(userQueries);
return userQueries;
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 documentation usequerqueries返回一个数组:
阵列中的每个元素都有以下属性:
,因此尝试在这样的循环中破坏数据:
如果您只对第一个结果感兴趣,则可以这样做:
According to the documentation useQueries returns an array:
Each element in the array has these properties:
So try destructing the data in a loop like this:
If you are only interested in the first result you could do it like this:
尝试删除参数“数据”
try removing the params "data"