Files
freeCodeCamp/client/gatsby-browser.js
Oliver Eyton-Williams e1c00138a9 fix: generate csrf tokens on server (#41968)
Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2021-05-10 21:40:42 +05:30

37 lines
991 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import cookies from 'browser-cookies';
import i18n from './i18n/config';
import { createStore } from './src/redux/createStore';
import AppMountNotifier from './src/components/AppMountNotifier';
import layoutSelector from './utils/gatsby/layoutSelector';
const store = createStore();
export const wrapRootElement = ({ element }) => {
return (
<Provider store={store}>
<I18nextProvider i18n={i18n}>
<AppMountNotifier render={() => element} />
</I18nextProvider>
</Provider>
);
};
wrapRootElement.propTypes = {
element: PropTypes.any
};
export const wrapPageElement = layoutSelector;
export const disableCorePrefetching = () => true;
export const onClientEntry = () => {
// purge the _csrf cookie, rather than relying what the browser decides a
// Session duration is
cookies.erase('_csrf');
};