我有几个使用用户详细信息的组件。
由于用户详细信息不会经常更改,因此我只想获取它们一次。
一种方法是 -
const twentyFourHoursInMs = 1000 * 60 * 60 * 24
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
refetchOnmount: false,
refetchOnReconnect: false,
retry: false,
staleTime: twentyFourHoursInMs,
},
},
})
Run Code Online (Sandbox Code Playgroud)
另一种方法是在基本组件中获取数据一次,并使用其他组件中的缓存数据queryClient.getQueryData('user')
哪种方式会更好?
我有一个渲染Tabs组件的组件Material UI 5.0.0-beta.5
有一种情况,我将此组件显示设置为无。
但是,然后我收到这个错误 -
Material-UI: The value provided to the Tabs component is invalid. The Tab with this value (0) is not part of the document layout. Make sure the tab item is present in the document or that it's not display none.
我理解该错误,并且我将其显示设置为无,因为但我想显示和隐藏该组件而不重新渲染(因为我希望用户选择持续存在)。
有没有办法解决这个错误,或者也许有更好的方法来完成我想做的事情?