Make url optional. Remove krustykrab from dependencies for react-select-fetch#191
Open
soteri-scottmmjackson wants to merge 1 commit intovtaits:masterfrom
Open
Conversation
vtaits
requested changes
Apr 16, 2025
| } | ||
| const paramsStr = stringifyParams(params); | ||
|
|
||
| const response: Response = await fetch(`${url}?${paramsStr}`, { |
Owner
There was a problem hiding this comment.
Looks like it would be better to do url ?? '' instead of throwing an error above.
There was a problem hiding this comment.
Is this different from setting url = "" default here?
I'd decided on throwing an error because it was least surprising compared to the previous behavior of throwing an inspection error.
I think I also might have found a minimal change with no associated functional code that would do it:
export type UseSelectFetchMapParams<
OptionType,
Group extends GroupBase<OptionType>,
> = ({ url: string, get: never} | {get: Get, url: never}) & {
queryParams?: {
[key: string]: unknown;
};
searchParamName?: string | null;
pageParamName?: string | null;
offsetParamName?: string | null;
mapResponse?: MapResponse<OptionType, Group>;
initialPage?: number;
defaultInitialPage?: number;
};I think this means we can have url xor get?
Owner
There was a problem hiding this comment.
This library aims to provide a convenient way to work with api endpoints. get is supposed to provide headers to request.
What is your case and why don't you use react-select-async-paginate for it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #190
Fixes #189