question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

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

See original GitHub issue

šŸ› 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ā€ https://github.com/facebook/react-native/blob/e6057095adfdc77ccbbff1c97b1e86b06dae340b/Libraries/Blob/URL.js#L69-L71

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: https://github.com/facebook/react-native/blob/e6057095adfdc77ccbbff1c97b1e86b06dae340b/Libraries/Core/setUpXHR.js#L31-L32

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:22
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

21reactions
leethreecommented, Apr 23, 2019

@matthargett the non-standard-compliant polyfill will cause issues because many 3rd-party libraries uses the global URL. I donā€™t think itā€™s reasonable to expect every app developer to throughly test whether this customised URL implementation is compatible with all the libraries. (That is why we have web standards in the first place.)

Many React Native applications use the included URL and URLSearchParams without issues

As you can see from the comments above, the new version breaks peopleā€™s apps with an obscure error even if it was working before. It means a breaking change was introduced without any documentation or workaround.

  1. If this URL implementation is intended to be used by app developers, it should be standard-compliant. I think URL and URLSearchParams are included in JavaScriptCore which is already provided by React Native 0.59. If that is the case, I donā€™t understand why we still need this customised URL implementation.

  2. If this URL implementation is only intended to be used internally by Blob, it should not be exported to the global scope. Or it should be renamed to something like RNURL to avoid confusing. App developers can actively decide if they want to use this customised version of URL.

In any case, its behaviour should be documented in some way. And a clear workaround should be provided with the error message.

10reactions
retyuicommented, Mar 25, 2019
// index.js

import { URL, URLSearchParams } from 'whatwg-url';
import { Buffer } from 'buffer';


// react-native 0.59 add own global URLSearchParams without implementation
// https://github.com/facebook/react-native/blob/e6057095adfdc77ccbbff1c97b1e86b06dae340b/Libraries/Blob/URL.js#L66
global.Buffer = Buffer;
global.URL = URL;
global.URLSearchParams = URLSearchParams;

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native URLSearchParams - Error: Not Implemented
The problem stems from the Supabase PostgREST-js library using the URLSearchParams Web API to convert this Supabase query into a URL.
Read more >
Can't find variable: URLSearchParams - Stack Overflow
In React Native 0.59, the developers "implemented" some methods of URLSearchParams with throw new Error('not implemented'); so... itĀ ...
Read more >
React Native 0.59+ URLSearchParams 'Error: not implemented'
Hi, i am trying to upgrade deepstream js client to v4, on React Native 0.61 but application seems to fail on this line...
Read more >
React Native恧Supabase-jsćŒå‹•ć‹ćŖ恄ļ¼ˆnot implementedćØ ...
[0.59.x] URLSearchParams 'Error: not implemented' Ā· Issue #23922 Ā· facebook/react-native. Bug Report I used next code to check supportĀ ...
Read more >
URLSearchParams - Web APIs - MDN Web Docs
Chrome Edge URLSearchParams Full support. Chrome49. Toggle history Full support. Edge... @@iterator Full support. Chrome49. Toggle history Full support. Edge... URLSearchParams() constructor Full support. Chrome49. Toggle...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found