Skip to content

Commit

Permalink
Fix minor homepage flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Feb 9, 2024
1 parent e2b5b3a commit 3c8c8ae
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/OnboardingSPA/steps/SiteGen/Preview/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import CommonLayout from '../../../components/Layouts/Common';

import { useEffect, useState } from '@wordpress/element';
import { useEffect, useState, useRef } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as nfdOnboardingStore } from '../../../store';
import { HEADER_SITEGEN } from '../../../../constants';
import { useNavigate } from 'react-router-dom';
// eslint-disable-next-line import/no-extraneous-dependencies
import { cloneDeep, isEmpty } from 'lodash';

import CommonLayout from '../../../components/Layouts/Common';
import { store as nfdOnboardingStore } from '../../../store';
import { HEADER_SITEGEN } from '../../../../constants';
import { SiteGenPreviewSelectableCard } from '../../../components/LivePreview';
import getContents from './contents';
import HeartAnimation from './heartAnimation';
import RegeneratingSiteCard from './regeneratingCard';
import { getHomepages, regenerateHomepage } from '../../../utils/api/siteGen';
import { getGlobalStyles } from '../../../utils/api/themes';
import SitegenAiStateHandler from '../../../components/StateHandlers/SitegenAi';
// eslint-disable-next-line import/no-extraneous-dependencies
import { cloneDeep, isEmpty } from 'lodash';

const SiteGenPreview = () => {
const navigate = useNavigate();
Expand All @@ -23,6 +22,8 @@ const SiteGenPreview = () => {
const [ isPreviewLoading, setIsPreviewLoading ] = useState( false );
const [ globalStyles, setGlobalStyles ] = useState( false );

const prevSiteGenErrorStatus = useRef();

const {
setIsHeaderEnabled,
setSidebarActiveView,
Expand Down Expand Up @@ -53,11 +54,18 @@ const SiteGenPreview = () => {
setHeaderActiveView( HEADER_SITEGEN );
setDrawerActiveView( false );
updateInitialize( true );
if ( ! siteGenErrorStatus ) {
}, [ currentData ] );

Check warning on line 57 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setSidebarActiveView', and 'updateInitialize'. Either include them or remove the dependency array

Check warning on line 57 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsHeaderEnabled', 'setSidebarActiveView', and 'updateInitialize'. Either include them or remove the dependency array

useEffect( () => {
if (
prevSiteGenErrorStatus.current === true &&
siteGenErrorStatus === false
) {
loadHomepages();
loadGlobalStyles();
}
}, [ currentData ] );
prevSiteGenErrorStatus.current = siteGenErrorStatus;
}, [ siteGenErrorStatus ] );

Check warning on line 68 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

Check warning on line 68 in src/OnboardingSPA/steps/SiteGen/Preview/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has a missing dependency: 'loadHomepages'. Either include it or remove the dependency array

const loadHomepages = async () => {
setIsPreviewLoading( true );
Expand Down

0 comments on commit 3c8c8ae

Please sign in to comment.