Safe document.location access

`document.location` is not defined in react-native.

Fixes #6512
This commit is contained in:
Benoit Dion 2019-04-15 20:32:54 -04:00
parent 632eabd37c
commit 59fa00cf78

View File

@ -2,7 +2,11 @@ import { document } from 'global';
import qs from 'qs';
export const getQueryParams = () => {
return qs.parse(document.location.search, { ignoreQueryPrefix: true });
// document.location is not defined in react-native
if (document && document.location && document.location.search) {
return qs.parse(document.location.search, { ignoreQueryPrefix: true });
}
return {};
};
export const getQueryParam = key => {