PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / PageCreator / pages / MainPage.jsx

MainPage.jsx in Extendify 3.2.1, at src/PageCreator/pages/MainPage.jsx

42 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { RetryNotice } from '@page-creator/components/RetryNotice';
2 import { usePagesStore } from '@page-creator/state/pages';
3 import { useState } from '@wordpress/element';
4 import { SWRConfig } from 'swr';
5
6 export const MainPage = ({ insertPage }) => {
7 const [retrying, setRetrying] = useState(false);
8 const { component: CurrentPage } = usePagesStore((state) =>
9 state.getCurrentPageData(),
10 );
11
12 const page = () => {
13 if (!CurrentPage) return null;
14 return <CurrentPage insertPage={insertPage} />;
15 };
16
17 return (
18 <SWRConfig
19 value={{
20 errorRetryInterval: 1000,
21 onErrorRetry: (error, _key, _config, revalidate, { retryCount }) => {
22 console.error(error);
23 if (error?.data?.status === 403) {
24 // if they are logged out, we can't recover
25 window.location.reload();
26 return;
27 }
28 if (retrying) return;
29 setRetrying(true);
30 setTimeout(() => {
31 setRetrying(false);
32 revalidate({ retryCount });
33 }, 5000);
34 },
35 }}
36 >
37 {page()}
38 <RetryNotice show={retrying} />
39 </SWRConfig>
40 );
41 };
42