We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given a basic component like the one below, response.isSuccess flashes false on subsequent queries.
response.isSuccess
Basic Example
import { useState } from "react"; import api from "./api"; export default function App() { const [params, setParams] = useState({ req: 0 }); const response = api.useSearchQuery(params); console.log( `request: ${params.req}\tisFetching: ${response.isFetching}\tisSuccess: ${response.isSuccess}` ); return ( <div> <button disabled={response.isFetching} onClick={() => setParams({ req: params.req + 1 })} > Refresh </button> <pre>{JSON.stringify(response, undefined, 3)}</pre> </div> ); }
Current Behavior in Console Log
request: 0 isFetching: true isSuccess: false request: 0 isFetching: true isSuccess: false request: 0 isFetching: false isSuccess: true request: 1 isFetching: true isSuccess: false <-- request: 1 isFetching: true isSuccess: true request: 1 isFetching: false isSuccess: true
Expected Behavior in Console Log
Given this quote from the documentation:
isSuccess - When true, indicates that the query has data from a successful request.
I would expect isSuccess to remain true while data is not undefined.
isSuccess
true
data
undefined
request: 0 isFetching: true isSuccess: false request: 0 isFetching: true isSuccess: false request: 0 isFetching: false isSuccess: true request: 1 isFetching: true isSuccess: true <-- request: 1 isFetching: true isSuccess: true request: 1 isFetching: false isSuccess: true
Repo to Reproduce: https://github.com/kellengreen/rtk
The text was updated successfully, but these errors were encountered:
Anyone?
Sorry, something went wrong.
Sorry, tbh we're all pretty busy with things lately and haven't had any time to try looking into assorted bugs.
No worries, I understand.
Confirmed still an issue in @reduxjs/toolkit = 2 and react-redux = 9.
@reduxjs/toolkit = 2
react-redux = 9
@markerikson We should look at the definition of isSuccess in the values in 'initialized' state.
const isSuccess = currentState.isSuccess || isFetching && hasData;
If the state is 'initialized', isFetching(isLoading) is false, so isSuccess is false even if hasData is true (when it has previous data).
Can I ask why isFetching & hasData condition is necessary?
isFetching & hasData
No branches or pull requests
Given a basic component like the one below,
response.isSuccess
flashes false on subsequent queries.Basic Example
Current Behavior in Console Log
Expected Behavior in Console Log
Given this quote from the documentation:
I would expect
isSuccess
to remaintrue
whiledata
is notundefined
.Repo to Reproduce:
https://github.com/kellengreen/rtk
The text was updated successfully, but these errors were encountered: