Fix ITSR repeated requests bug
Summary: I converted the rating button to a functional component, and mistakenly moved the effect in the constructor into the render function. This puts it into an effect with no dependencies so it should only happen once, instead of every render. Reviewed By: mweststrate Differential Revision: D25185514 fbshipit-source-id: 48203b01bbd85f3b9ed4dbbb416768c0d5524f70
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8025c49768
commit
0f51ae4b82
@@ -7,7 +7,14 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import React, {Component, ReactElement, RefObject, useState} from 'react';
|
||||
import React, {
|
||||
Component,
|
||||
ReactElement,
|
||||
RefObject,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useState,
|
||||
} from 'react';
|
||||
import {
|
||||
Glyph,
|
||||
FlexColumn,
|
||||
@@ -373,19 +380,21 @@ export function SandyRatingButton() {
|
||||
const [hasTriggered, setHasTriggered] = useState(false);
|
||||
const sessionId = useStore((store) => store.application.sessionId);
|
||||
|
||||
const triggerPopover = () => {
|
||||
const triggerPopover = useCallback(() => {
|
||||
if (!hasTriggered) {
|
||||
setIsShown(true);
|
||||
setHasTriggered(true);
|
||||
}
|
||||
};
|
||||
}, [hasTriggered]);
|
||||
|
||||
if (GK.get('flipper_enable_star_ratiings')) {
|
||||
UserFeedback.getPrompt().then((prompt) => {
|
||||
setPromptData(prompt);
|
||||
setTimeout(triggerPopover, 30000);
|
||||
});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (GK.get('flipper_enable_star_ratiings') && !hasTriggered) {
|
||||
UserFeedback.getPrompt().then((prompt) => {
|
||||
setPromptData(prompt);
|
||||
setTimeout(triggerPopover, 30000);
|
||||
});
|
||||
}
|
||||
}, [triggerPopover, hasTriggered]);
|
||||
|
||||
const onClick = () => {
|
||||
const willBeShown = !isShown;
|
||||
|
||||
Reference in New Issue
Block a user