我如何比较 useParams() 上一个值和当前值
我面临一个问题,我根据 params?.id 获取不同的 api。我需要使用 rtkQuery 比较 api 调用的先前和当前 useParams。但它并没有在 useparams 更改时调用我的 api。
const {
data: pipelineData,
isLoading: pipelineDataLoading,
error: pipelineDataError,
isSuccess: pipelineDataSuccess,
} = pipeline.list().usePipelinedetailQuery(
{ params: { id: params.pipelineId }, extendedPath: apiUrls.getPipeline() },
{
skip: !params?.pipelineId,
},
);
我想使用类似skip: if prev.params.id !== prams.id 的内容。 有两种方法可以做到这一点。 =>通过设置一个状态来存储useParams的上一个值。 =>通过使用rtk查询提供的reffecthh。
还有其他正宗的方法吗?
任何帮助将不胜感激。
I am facing a problem where I am fetching different api's based on params?.id. I need to compare the prev and current useParams for an api call using rtkQuery. But it is not recalling my api on useparams change.
const {
data: pipelineData,
isLoading: pipelineDataLoading,
error: pipelineDataError,
isSuccess: pipelineDataSuccess,
} = pipeline.list().usePipelinedetailQuery(
{ params: { id: params.pipelineId }, extendedPath: apiUrls.getPipeline() },
{
skip: !params?.pipelineId,
},
);
I want to use something like skip: if prev.params.id !== prams.id.
there are two ways to do it.
=>By setting a state to store prev value of useParams.
=>by using refecthh provided by rtk query.
Is there any other authhentic way to do it.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论