🐛 répare la page blanche en cas de blocage des cookie par l'utilisateur
parent
4cf4318df5
commit
c4119fc509
|
@ -2,16 +2,12 @@ import i18next from 'i18next'
|
|||
import queryString from 'query-string'
|
||||
import { initReactI18next } from 'react-i18next'
|
||||
import enTranslations from './locales/en.yaml'
|
||||
import { getIframeOption, parseDataAttributes } from './utils'
|
||||
|
||||
let getFromSessionStorage = where =>
|
||||
typeof sessionStorage !== 'undefined' ? sessionStorage[where] : null
|
||||
|
||||
let setToSessionStorage = (where, what) =>
|
||||
typeof sessionStorage !== 'undefined' &&
|
||||
do {
|
||||
sessionStorage[where] = what
|
||||
}
|
||||
import {
|
||||
getFromSessionStorage,
|
||||
getIframeOption,
|
||||
parseDataAttributes,
|
||||
setToSessionStorage
|
||||
} from './utils'
|
||||
|
||||
let lang =
|
||||
getIframeOption('lang') ||
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
retrievePersistedSimulation
|
||||
} from '../../storage/persistSimulation'
|
||||
import ReactPiwik from '../../Tracker'
|
||||
import { inIframe } from '../../utils'
|
||||
import { inIframe, setToSessionStorage } from '../../utils'
|
||||
import './App.css'
|
||||
import Footer from './layout/Footer/Footer'
|
||||
import Header from './layout/Header/Header'
|
||||
|
@ -60,9 +60,7 @@ const middlewares = [
|
|||
|
||||
class InFranceRoute extends Component {
|
||||
componentDidMount() {
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
sessionStorage['lang'] = this.props.language
|
||||
}
|
||||
setToSessionStorage('lang', this.props.language)
|
||||
}
|
||||
render() {
|
||||
const paths = constructLocalizedSitePath(this.props.language)
|
||||
|
|
|
@ -66,7 +66,7 @@ export function inIframe() {
|
|||
}
|
||||
}
|
||||
|
||||
export function softCatch<ArgType: any, ReturnType: any>(
|
||||
export function softCatch<ArgType: mixed, ReturnType: mixed>(
|
||||
fn: ArgType => ReturnType
|
||||
): ArgType => ReturnType | null {
|
||||
return function(...args) {
|
||||
|
@ -102,3 +102,13 @@ export const constructSitePaths = (
|
|||
sitePaths
|
||||
)
|
||||
})
|
||||
|
||||
export const getFromSessionStorage = softCatch<string, any>(where => {
|
||||
typeof sessionStorage !== 'undefined' ? sessionStorage[where] : null
|
||||
})
|
||||
|
||||
export const setToSessionStorage = softCatch<string, void>((where, what) => {
|
||||
if (typeof sessionStorage !== 'undefined') {
|
||||
sessionStorage[where] = what
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue