Fix URLSearchParams usage for react-native

This commit is contained in:
Jorrin
2024-02-29 22:44:38 +01:00
parent c735ce33a0
commit 36d4b41baa
4 changed files with 26 additions and 16 deletions

9
src/utils/native.ts Normal file
View File

@@ -0,0 +1,9 @@
export const isReactNative = () => {
try {
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
require('react-native');
return true;
} catch (e) {
return false;
}
};

View File

@@ -1,5 +0,0 @@
export function createSearchParams(params: { [key: string]: string | number }): string {
return Object.entries(params)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&');
}