score:0
here's what i think the issue was, and how i solved it.
because i set staletime: infinity
in my reactqueryconfigproider
, i expected all of my queries to never go stale.
what's different about this query is i invalidate it when something not driven by the ui happens.
i have a session timer in my code that, when the session expired, calls querycache.invalidatequeries('profile')
to trigger any ui displaying the profile to re-render.
it appears that if invalidatequeries
is ever called outside the context of a query, the settings in reactqueryconfigproider
are not observed, so staletime
is set to the default, 0.
to resolve this, for the queries i need to invalidate on a timer, i added { staletime: infinity }
to the query explicitly:
export const useprofile = () => {
const { data: session } = usesession();
const userid = session?.userid;
return usequery(['profile', userid], getprofile, { staletime: infinity });
};
i won't go so far as to say this is a bug in react-query, but this seems to be a workaround.
score:0
i ran into the same problem, and it was caused by a component that had a child component which used react-query. check your component tree and make sure nothing uses useprofile() outside of <reactqueryconfigprovider>
.
Source: stackoverflow.com
Related Query
- react-query: why is this one query always stale?
- Why i am not getting dropdown in react js can any one solve me this
- Why can't I push this information from one react component to another?
- why we cannot pass boolean value as props in React , it always demands string to be passed in my code
- with react final-form why is meta.touched always false with third party components?
- Suddenly React cannot execute the 'create-react-app' command. Why is this happening and how can I solve it?
- Why Code Coverage in react app is empty? Tried using npm run test -- --coverage. But always showing empty code coverage
- Javascript: What is eslintcache file and why is always generated in create react app
- Why I am getting this error message when I run react js project first time in my system?
- Why does react class component always need to call super(props) in its constructor?
- React Router: Update only one query parameter instead of replacing all
- Why is this react component rendering twice?
- React Hooks state always one step behind
- React tutorial- why binding this in ajax call
- Why is clearTimeout not clearing the timeout in this react component?
- Why is this not scoped in React form onSubmit function?
- Why React does't compare Previous State and New State before re rendering? Why it always render when setState is called?
- React - Why is binding this not required in this example?
- Why is this component switching from controlled to uncontrolled? - React
- Why should one use React with Meteor?
- How can I remove this switch case when the React Element name is always the same as the switch variable?
- Why graphQLErrors are always empty in react components?
- Apollo React Why Can't Query inside UseEffect hook
- Why is this variable from the Redux store not in the `this.props` on React page?
- Why react calls function in subcomponents event when this subsomponents not rendered?
- why is mouseup event not firing when releasing outside div in this react code (using window.addEventListener)
- Why does React Router v6 seem unable to remove query string param from URL?
- why boolean variable is passed to useState() is always false? React hooks
- Why does this official React testing recipe using await/act/async actually work?
- Why doesn't this component show at all? React DatePicker
More Query from same tag
- changing prototype of required React component
- Passing 'this' to Axios promise 'then'?
- How to write tests for Component that uses Table component material UI?
- React Material UI 2 TableRows in one loop error
- React Testing Library unable to find text even though screen.debug() shows the text to exist
- Can I use matchPath without a child component?
- How to TEST async calls made in componentDidMount that set the state of React Component
- Convert date dd/mm/yyyy to cyymmdd
- How do I deploy a static React "app" to Heroku?
- [Flow]react-native: Required module not found
- Nextjs not correctly load GetStaticProps and not return props to page
- How do I update the default useSate value from a html input?
- navigate('/') doesn't navigate
- React-Admin: How to edit another Component value after 1 has changed (eg, subtotal+discount=total)?
- Cannot read property 'setState' of null - React.js, Modal, Bootstrap
- Express server routing issue - does not allow for other routes only home route working
- Filtering data in react-query
- How do i use styled components with dynamic imports
- Which strategy to use when displaying a value on the screen that comes from a useState hook of React and not re render unless under an action?
- Module not found : 'child process'
- How to fire a function on clicking by a dynamically added button in React?
- Add Dropdown Component to Material-Table Actions
- How to update a useCallback hook on a event
- Dynamic Width Measurement: ReactJS/NodeJS & HTML/CSS
- React Not returning Child from map loop when creating SVG from JSON object
- EventListener does not get removed on function call
- I am getting an error in the JSX while calling a function inside it
- Is it possible to modify a store from another store?
- How do I fire React useEffect hook only once after state change?
- PrevState typing in TypeScript