我的问题是图像中显示的控制台消息不停地打印。
的数据
当应用程序启动时,没有任何消息。但是,当我保存一些更改时,它开始显示控制台消息。
我已经找到了有问题的组件(如果我不使用它,问题就不会发生),但我找不到任何问题。
这是产生问题的组件的父组件(注解了props以将组件简化到最小):
<MainInitialPage
/*categories={categories}
handleCategorySelect={this.handleCategorySelect}
onInit={this.onInit}
userData={userData}*/
/>
字符串
这是出现问题的组件(就像父组件一样,代码被注解以将其简化到极限):
import React /*, { useContext, useEffect, useState }*/ from 'react';
/*import Category from '../../../../../shared/domain/category/category.model';
import SayCasesEnum from '../../../../../shared/domain/screen-speech-enablement/say-cases-enum';
import { AlvicButton } from '../..';
import { ButtonPreset } from '../../alvic-button/button-presets';
import CategorySelect from '../../categorySelect/categorySelect';
import { ConfigurationContext } from '../../../contexts/configuration/configuration.context';
import { translate } from '../../../utils/translate';
import { MainTitle } from '../mainTitle/mainTitle';
import { MainInitialPageProps } from './types';
import { take } from 'rxjs';
import EmptyObserver from '../../../utils/empty-observer';
import { withSay } from '../../hoc/withConfigPurchaseSay';
import { withLanguageState } from '../../hoc';*/
const MainInitialPage: React.FC /*<MainInitialPageProps> = (props)*/ = () => {
/*const t = translate();
const { categories, handleCategorySelect, onInit, userData, say$, language } =
props;
// State to know when "Welcome" message has to be played
const [languageState, setLanguageState] = useState<string>('');
const configuration = useContext(ConfigurationContext);
//Only update languageState when language is deferent from the previous one
/*useEffect(() => {
if (languageState !== language.name) setLanguageState(language.name);
}, [language]);
useEffect(() => {
say$(
userData?.userName
? SayCasesEnum.CancelOperationVerification
: SayCasesEnum.Main
)
.pipe(take(1))
.subscribe(EmptyObserver);
}, [userData?.userName, languageState]);*/
/*const isCategorySelectionAvailable = (
isCategorySelectionEnabled: boolean = false,
selectProductBeforePump: boolean = false,
categories: Category[]
): boolean => {
const availableCategories = categories.filter(
(category) => category.available === true
);
if (
availableCategories.length > 1 &&
isCategorySelectionEnabled &&
selectProductBeforePump
)
return true;
return false;
};
const getTitleText = (): string => {
if (
userData?.userName &&
!configuration?.configuration?.ux.showUserNameInWelcomeMessage
)
return t('main_title_logged_in_without_username');
if (userData?.userName)
return t('main_title_logged_in_with_username')
.toString()
.replace('%USERNAME%', String(userData?.userName));
return t('main_title').toString();
};*/
return (
<div className="main-body-center-container">
ab
{/*<MainTitle
title={getTitleText()}
subtitle={t('main_subtitle').toString()}
showSubtitle={isCategorySelectionAvailable(
configuration?.configuration?.ux.categorySelection,
configuration?.configuration?.ux.selectProductBeforePump,
categories
)}
/>
<div className="main-categories-selection">
{isCategorySelectionAvailable(
configuration?.configuration?.ux.categorySelection,
configuration?.configuration?.ux.selectProductBeforePump,
categories
) ? (
<CategorySelect
categories={categories}
onClickHandler={handleCategorySelect}
screenLog="Main"
/>
) : (
<AlvicButton
id="main-start-button"
preset={ButtonPreset.Information}
onClick={() => onInit(configuration?.configuration)}
>
<span className="emphasis-3">
{t('landing_start_button').toString()}
</span>
</AlvicButton>
)}
</div>*/}
</div>
);
};
export default /*withSay(withLanguageState(*/ MainInitialPage; /*));*/
型
我不知道这个问题是否与此有关,但我正在使用电子。
我已经尝试注解掉所有不需要呈现它的组件代码。
1条答案
按热度按时间dgiusagp1#
我终于找到了!问题是文件名。
在父组件中,导入为:从“../../components/main/mainBody/mainInitialPage”导入MainInitialPage;而文件名为MainInitialPage.ts