Skip to content
Snippets Groups Projects
Commit ecc2d281 authored by Nicolò Pretto's avatar Nicolò Pretto
Browse files

Revert "fix(sdk): put a bandage on the flashing error on static question in strict mode (#49659)"

This reverts commit c57b3a38.
parent 9fb6328c
No related branches found
No related tags found
No related merge requests found
import { useEffect, useRef, useState } from "react";
import { useEffect, useState } from "react";
import { loadStaticQuestion } from "embedding-sdk/lib/load-static-question";
import type { GenericErrorResponse } from "metabase/lib/errors";
......@@ -17,17 +17,6 @@ export function useLoadStaticQuestion(
questionId: number | null,
parameterValues?: Record<string, string | number>,
) {
// This is a hack around strict mode calling the useEffect twice ->
// the first request is being cancelled and we render a error state for a few renders
// This needs to start at true, it needs to bypass the double use effect of strict mode
// See https://github.com/metabase/metabase/issues/49620 for more details on the issue
const isMounted = useRef(true);
useEffect(() => {
return () => {
isMounted.current = false;
};
}, []);
const [questionState, setQuestionState] = useState<QuestionState>({
loading: false,
card: null,
......@@ -67,10 +56,6 @@ export function useLoadStaticQuestion(
error: null,
});
} catch (error) {
if (!isMounted.current) {
return;
}
if (typeof error === "object") {
setQuestionState({
result: null,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment