-
Notifications
You must be signed in to change notification settings - Fork 0
Issue #8469 - fix(solid-query): client() doesn't return undefined #3
New issue
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,11 @@ export function useBaseQuery< | |
) { | ||
type ResourceData = QueryObserverResult<TData, TError> | ||
|
||
const client = createMemo(() => useQueryClient(queryClient?.())) | ||
const client = createMemo( | ||
() => useQueryClient(queryClient?.()), | ||
useQueryClient(queryClient?.()), | ||
) | ||
Comment on lines
+119
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed client initialization by providing initial value to createMemo. This change ensures that the query client is properly initialized with an initial value, resolving the issue where The second parameter to |
||
|
||
const isRestoring = useIsRestoring() | ||
// There are times when we run a query on the server but the resource is never read | ||
// This could lead to times when the queryObserver is unsubscribed before the resource has loaded | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintainability Issue: The
createMemo
function inuseBaseQuery.ts
has been modified to provide an initial value, which is a good practice for maintainability.This change improves code predictability by ensuring the
client
memo always has a valid initial value rather than potentially being undefined on first access. This makes the component behavior more consistent and reduces the risk of unexpected errors.For even better maintainability, consider adding a brief comment explaining why the initial value is important: