Skip to content

Redundant API calls even after the Frigade.Provider is unmounted #446

@afzalzbr

Description

@afzalzbr

Hi, I am using Frigade in my NextJs project.

I have implemented Frigade in a way that it checks if the user hasn't completed the flow then it will show the frigade and if the user has completed the flow, it will hide the onboarding. In fact, it will unmount the FrigadeProvider component and theoretically speaking there won't be any unnecessary calls from Frigade. However, I can see there are still many calls in Network Tab. See the image below

Image

See the my coding logic for conditional rendering of FrigadeProvider

// ✅ If no user is logged in or onboarding is complete, render app without Frigade
if (!FRIGADE_API_KEY || onboardingComplete) {
	const reason = !FRIGADE_API_KEY
		? "No Frigade API key available"
		: "Onboarding already completed";
	console.debug(`Loading app without Frigade: ${reason}`);
	return <>{children}</>;
}

// ✅ Wrap app with Frigade provider only when user is logged in and onboarding is not complete
return (
	<Frigade.Provider
		apiKey={FRIGADE_API_KEY}
		css={frigadeCss}
		userId={userId || undefined}
		theme={frigadeTheme}
	>
		{children}
	</Frigade.Provider>
);

PS: onboardingComplete is true.

Can you please help me out if I'm doing anything wrong here. Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions