freeCodeCamp/client/gatsby-browser.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import cookies from 'browser-cookies';
import PropTypes from 'prop-types';
import React from 'react';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import i18n from './i18n/config';
import AppMountNotifier from './src/components/app-mount-notifier';
import { createStore } from './src/redux/createStore';
import layoutSelector from './utils/gatsby/layout-selector';
const store = createStore();
export const wrapRootElement = ({ element }) => {
2018-08-30 14:27:53 +00:00
return (
<Provider store={store}>
<I18nextProvider i18n={i18n}>
<AppMountNotifier render={() => element} />
</I18nextProvider>
2018-08-30 14:27:53 +00:00
</Provider>
);
};
wrapRootElement.propTypes = {
element: PropTypes.any
};
2019-02-28 15:44:35 +00:00
export const wrapPageElement = layoutSelector;
export const disableCorePrefetching = () => true;
export const onClientEntry = () => {
// purge the csrf cookies, rather than relying what the browser decides a
// Session duration is
cookies.erase('_csrf');
// the token must be erased since it is only valid for the old _csrf secret
cookies.erase('csrf_token');
};