Skip to content

[0.59.x] URLSearchParams 'Error: not implemented' #23922

@retyui

Description

@retyui

🐛 Bug Report

I used next code to check support URLSearchParams

if ( !global.URLSearchParams ) {
   global.URLSearchParams = require('url-search-params')
}

But now it doesn't work because you add own "implementation"

get(name) {
throw new Error('not implemented');
}

And a can't overwrite it

To Reproduce

const a = new URLSearchParams()
a.set('1','2');
a.toString()

Expected Behavior

My code don't broken!

Remove these polyfills:

polyfillGlobal('URL', () => require('URL').URL); // flowlint-line untyped-import:off
polyfillGlobal('URLSearchParams', () => require('URL').URLSearchParams); // flowlint-line untyped-import:off

Code Example

// I try force set custom 
global.URLSearchParams = require('url-search-params');

// But it works only with
import { polyfillGlobal } from 'react-native/Libraries/Utilities/PolyfillFunctions';

polyfillGlobal('URLSearchParams', () => require('url-search-params'));

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.15 Linux Mint 19.1 (Tessa)
      CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 1.27 GB / 15.51 GB
      Shell: 2.7.1 - /usr/bin/fish
    Binaries:
      Node: 10.15.3 - /usr/bin/node
      Yarn: 1.13.0 - /usr/bin/yarn
      npm: 6.4.1 - /usr/bin/npm
    npmPackages:
      react: ^16.8.1 => 16.8.4 
      react-native: ^0.59.0 => 0.59.0 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions