Remove `qs` dependency from `<_Layout>`,

use native `URLSearchParams` instead.
This commit is contained in:
Tomek Wytrębowicz 2022-10-17 16:39:19 +02:00
parent c3888d658e
commit 1002f06d07
1 changed files with 3 additions and 11 deletions

View File

@ -16,7 +16,6 @@ import {
import { Children, cloneElement } from 'react'; import { Children, cloneElement } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { get, isFunction, identity, memoize } from 'lodash'; import { get, isFunction, identity, memoize } from 'lodash';
import { parse } from 'qs';
import { getHistory, getQuery } from '@woocommerce/navigation'; import { getHistory, getQuery } from '@woocommerce/navigation';
import { import {
PLUGINS_STORE_NAME, PLUGINS_STORE_NAME,
@ -190,15 +189,6 @@ class _Layout extends Component {
} ); } );
} }
getQuery( searchString ) {
if ( ! searchString ) {
return {};
}
const search = searchString.substring( 1 );
return parse( search );
}
isWCPaySettingsPage() { isWCPaySettingsPage() {
const { page, section, tab } = getQuery(); const { page, section, tab } = getQuery();
return ( return (
@ -212,7 +202,9 @@ class _Layout extends Component {
const { isEmbedded, ...restProps } = this.props; const { isEmbedded, ...restProps } = this.props;
const { location, page } = this.props; const { location, page } = this.props;
const { breadcrumbs } = page; const { breadcrumbs } = page;
const query = this.getQuery( location && location.search ); const query = Object.fromEntries(
new URLSearchParams( location && location.search )
);
return ( return (
<LayoutContext.Provider <LayoutContext.Provider