- [x] I have read [freeCodeCamp's contribution guidelines](https://github.com/freeCodeCamp/freeCodeCamp/blob/master/CONTRIBUTING.md). - [x] My pull request has a descriptive title (not a vague title like `Update index.md`) - [x] My pull request targets the `master` branch of freeCodeCamp. - [x] None of my changes are plagiarized from another source without proper attribution. Closes #35418 It disables only prefetching on link become visible, other prefetching strategies like prefetching on link hover still work.
62 lines
1.5 KiB
JavaScript
62 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { createStore } from './src/redux/createStore';
|
|
import AppMountNotifier from './src/components/AppMountNotifier';
|
|
|
|
import {
|
|
CertificationLayout,
|
|
DefaultLayout,
|
|
GuideLayout
|
|
} from './src/components/layouts';
|
|
|
|
const store = createStore();
|
|
|
|
export const wrapRootElement = ({ element }) => {
|
|
return (
|
|
<Provider store={store}>
|
|
<AppMountNotifier render={() => element} />
|
|
</Provider>
|
|
);
|
|
};
|
|
|
|
wrapRootElement.propTypes = {
|
|
element: PropTypes.any
|
|
};
|
|
|
|
export const wrapPageElement = ({ element, props }) => {
|
|
const {
|
|
location: { pathname }
|
|
} = props;
|
|
if (pathname === '/') {
|
|
return (
|
|
<DefaultLayout disableSettings={true} landingPage={true}>
|
|
{element}
|
|
</DefaultLayout>
|
|
);
|
|
}
|
|
if (/^\/certification(\/.*)*/.test(pathname)) {
|
|
return <CertificationLayout>{element}</CertificationLayout>;
|
|
}
|
|
if (/^\/guide(\/.*)*/.test(pathname)) {
|
|
return (
|
|
<DefaultLayout onGuide={true}>
|
|
<GuideLayout>{element}</GuideLayout>
|
|
</DefaultLayout>
|
|
);
|
|
}
|
|
if (/^\/learn(\/.*)*/.test(pathname)) {
|
|
return <DefaultLayout showFooter={false}>{element}</DefaultLayout>;
|
|
}
|
|
return <DefaultLayout>{element}</DefaultLayout>;
|
|
};
|
|
|
|
wrapPageElement.propTypes = {
|
|
element: PropTypes.any,
|
|
location: PropTypes.objectOf({ pathname: PropTypes.string }),
|
|
props: PropTypes.any
|
|
};
|
|
|
|
export const disableCorePrefetching = () => true;
|